route: add GRPC bindings for the planned API requests
This commit is contained in:
parent
835ddb4762
commit
a14eebb496
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
protoc -I/usr/local/include -I. \
|
||||
-I$GOPATH/src \
|
||||
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
|
||||
--go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \
|
||||
route.proto
|
||||
|
||||
protoc -I/usr/local/include -I. \
|
||||
-I$GOPATH/src \
|
||||
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
|
||||
--grpc-gateway_out=logtostderr=true:. \
|
||||
route.proto
|
|
@ -0,0 +1,699 @@
|
|||
// Code generated by protoc-gen-go.
|
||||
// source: route.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package route is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
route.proto
|
||||
|
||||
It has these top-level messages:
|
||||
BaseAPICall
|
||||
Host
|
||||
AddHostRequest
|
||||
AddHostResponse
|
||||
RemoveHostRequest
|
||||
RemoveHostResponse
|
||||
GetHostRequest
|
||||
GetHostResponse
|
||||
CreateInitialTokenRequest
|
||||
CreateInitialTokenResponse
|
||||
LoginRequest
|
||||
LoginResponse
|
||||
*/
|
||||
package route
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import _ "github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type BaseAPICall struct {
|
||||
Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"`
|
||||
}
|
||||
|
||||
func (m *BaseAPICall) Reset() { *m = BaseAPICall{} }
|
||||
func (m *BaseAPICall) String() string { return proto.CompactTextString(m) }
|
||||
func (*BaseAPICall) ProtoMessage() {}
|
||||
func (*BaseAPICall) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
func (m *BaseAPICall) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Host struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
||||
Hostname string `protobuf:"bytes,2,opt,name=hostname" json:"hostname,omitempty"`
|
||||
OnionHostname string `protobuf:"bytes,3,opt,name=onionHostname" json:"onionHostname,omitempty"`
|
||||
Token string `protobuf:"bytes,4,opt,name=token" json:"token,omitempty"`
|
||||
OnionKey []byte `protobuf:"bytes,5,opt,name=onionKey,proto3" json:"onionKey,omitempty"`
|
||||
Kind int32 `protobuf:"varint,6,opt,name=kind" json:"kind,omitempty"`
|
||||
Port string `protobuf:"bytes,7,opt,name=port" json:"port,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Host) Reset() { *m = Host{} }
|
||||
func (m *Host) String() string { return proto.CompactTextString(m) }
|
||||
func (*Host) ProtoMessage() {}
|
||||
func (*Host) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||
|
||||
func (m *Host) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Host) GetHostname() string {
|
||||
if m != nil {
|
||||
return m.Hostname
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Host) GetOnionHostname() string {
|
||||
if m != nil {
|
||||
return m.OnionHostname
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Host) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Host) GetOnionKey() []byte {
|
||||
if m != nil {
|
||||
return m.OnionKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Host) GetKind() int32 {
|
||||
if m != nil {
|
||||
return m.Kind
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Host) GetPort() string {
|
||||
if m != nil {
|
||||
return m.Port
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type AddHostRequest struct {
|
||||
Base *BaseAPICall `protobuf:"bytes,1,opt,name=base" json:"base,omitempty"`
|
||||
Hostname string `protobuf:"bytes,2,opt,name=hostname" json:"hostname,omitempty"`
|
||||
OnionKey []byte `protobuf:"bytes,3,opt,name=onionKey,proto3" json:"onionKey,omitempty"`
|
||||
}
|
||||
|
||||
func (m *AddHostRequest) Reset() { *m = AddHostRequest{} }
|
||||
func (m *AddHostRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*AddHostRequest) ProtoMessage() {}
|
||||
func (*AddHostRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||
|
||||
func (m *AddHostRequest) GetBase() *BaseAPICall {
|
||||
if m != nil {
|
||||
return m.Base
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AddHostRequest) GetHostname() string {
|
||||
if m != nil {
|
||||
return m.Hostname
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *AddHostRequest) GetOnionKey() []byte {
|
||||
if m != nil {
|
||||
return m.OnionKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type AddHostResponse struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
||||
Token string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
|
||||
Hostname string `protobuf:"bytes,3,opt,name=hostname" json:"hostname,omitempty"`
|
||||
OnionHostname string `protobuf:"bytes,4,opt,name=onionHostname" json:"onionHostname,omitempty"`
|
||||
}
|
||||
|
||||
func (m *AddHostResponse) Reset() { *m = AddHostResponse{} }
|
||||
func (m *AddHostResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*AddHostResponse) ProtoMessage() {}
|
||||
func (*AddHostResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
|
||||
|
||||
func (m *AddHostResponse) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *AddHostResponse) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *AddHostResponse) GetHostname() string {
|
||||
if m != nil {
|
||||
return m.Hostname
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *AddHostResponse) GetOnionHostname() string {
|
||||
if m != nil {
|
||||
return m.OnionHostname
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type RemoveHostRequest struct {
|
||||
Base *BaseAPICall `protobuf:"bytes,1,opt,name=base" json:"base,omitempty"`
|
||||
Host string `protobuf:"bytes,2,opt,name=host" json:"host,omitempty"`
|
||||
}
|
||||
|
||||
func (m *RemoveHostRequest) Reset() { *m = RemoveHostRequest{} }
|
||||
func (m *RemoveHostRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*RemoveHostRequest) ProtoMessage() {}
|
||||
func (*RemoveHostRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
|
||||
|
||||
func (m *RemoveHostRequest) GetBase() *BaseAPICall {
|
||||
if m != nil {
|
||||
return m.Base
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *RemoveHostRequest) GetHost() string {
|
||||
if m != nil {
|
||||
return m.Host
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type RemoveHostResponse struct {
|
||||
Success bool `protobuf:"varint,1,opt,name=success" json:"success,omitempty"`
|
||||
}
|
||||
|
||||
func (m *RemoveHostResponse) Reset() { *m = RemoveHostResponse{} }
|
||||
func (m *RemoveHostResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*RemoveHostResponse) ProtoMessage() {}
|
||||
func (*RemoveHostResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
|
||||
|
||||
func (m *RemoveHostResponse) GetSuccess() bool {
|
||||
if m != nil {
|
||||
return m.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type GetHostRequest struct {
|
||||
Base *BaseAPICall `protobuf:"bytes,1,opt,name=base" json:"base,omitempty"`
|
||||
Host string `protobuf:"bytes,2,opt,name=host" json:"host,omitempty"`
|
||||
OnionHost string `protobuf:"bytes,3,opt,name=onionHost" json:"onionHost,omitempty"`
|
||||
Id string `protobuf:"bytes,4,opt,name=id" json:"id,omitempty"`
|
||||
}
|
||||
|
||||
func (m *GetHostRequest) Reset() { *m = GetHostRequest{} }
|
||||
func (m *GetHostRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetHostRequest) ProtoMessage() {}
|
||||
func (*GetHostRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
|
||||
|
||||
func (m *GetHostRequest) GetBase() *BaseAPICall {
|
||||
if m != nil {
|
||||
return m.Base
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetHostRequest) GetHost() string {
|
||||
if m != nil {
|
||||
return m.Host
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetHostRequest) GetOnionHost() string {
|
||||
if m != nil {
|
||||
return m.OnionHost
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetHostRequest) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetHostResponse struct {
|
||||
Host *Host `protobuf:"bytes,1,opt,name=host" json:"host,omitempty"`
|
||||
}
|
||||
|
||||
func (m *GetHostResponse) Reset() { *m = GetHostResponse{} }
|
||||
func (m *GetHostResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetHostResponse) ProtoMessage() {}
|
||||
func (*GetHostResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
|
||||
|
||||
func (m *GetHostResponse) GetHost() *Host {
|
||||
if m != nil {
|
||||
return m.Host
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type CreateInitialTokenRequest struct {
|
||||
Username string `protobuf:"bytes,1,opt,name=username" json:"username,omitempty"`
|
||||
}
|
||||
|
||||
func (m *CreateInitialTokenRequest) Reset() { *m = CreateInitialTokenRequest{} }
|
||||
func (m *CreateInitialTokenRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*CreateInitialTokenRequest) ProtoMessage() {}
|
||||
func (*CreateInitialTokenRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
|
||||
|
||||
func (m *CreateInitialTokenRequest) GetUsername() string {
|
||||
if m != nil {
|
||||
return m.Username
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CreateInitialTokenResponse struct {
|
||||
Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"`
|
||||
Tokenid string `protobuf:"bytes,2,opt,name=tokenid" json:"tokenid,omitempty"`
|
||||
}
|
||||
|
||||
func (m *CreateInitialTokenResponse) Reset() { *m = CreateInitialTokenResponse{} }
|
||||
func (m *CreateInitialTokenResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*CreateInitialTokenResponse) ProtoMessage() {}
|
||||
func (*CreateInitialTokenResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
|
||||
|
||||
func (m *CreateInitialTokenResponse) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CreateInitialTokenResponse) GetTokenid() string {
|
||||
if m != nil {
|
||||
return m.Tokenid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type LoginRequest struct {
|
||||
Oauth2Provider string `protobuf:"bytes,1,opt,name=oauth2provider" json:"oauth2provider,omitempty"`
|
||||
}
|
||||
|
||||
func (m *LoginRequest) Reset() { *m = LoginRequest{} }
|
||||
func (m *LoginRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*LoginRequest) ProtoMessage() {}
|
||||
func (*LoginRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
|
||||
|
||||
func (m *LoginRequest) GetOauth2Provider() string {
|
||||
if m != nil {
|
||||
return m.Oauth2Provider
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"`
|
||||
Uid string `protobuf:"bytes,2,opt,name=uid" json:"uid,omitempty"`
|
||||
}
|
||||
|
||||
func (m *LoginResponse) Reset() { *m = LoginResponse{} }
|
||||
func (m *LoginResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*LoginResponse) ProtoMessage() {}
|
||||
func (*LoginResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
|
||||
|
||||
func (m *LoginResponse) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *LoginResponse) GetUid() string {
|
||||
if m != nil {
|
||||
return m.Uid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*BaseAPICall)(nil), "BaseAPICall")
|
||||
proto.RegisterType((*Host)(nil), "Host")
|
||||
proto.RegisterType((*AddHostRequest)(nil), "AddHostRequest")
|
||||
proto.RegisterType((*AddHostResponse)(nil), "AddHostResponse")
|
||||
proto.RegisterType((*RemoveHostRequest)(nil), "RemoveHostRequest")
|
||||
proto.RegisterType((*RemoveHostResponse)(nil), "RemoveHostResponse")
|
||||
proto.RegisterType((*GetHostRequest)(nil), "GetHostRequest")
|
||||
proto.RegisterType((*GetHostResponse)(nil), "GetHostResponse")
|
||||
proto.RegisterType((*CreateInitialTokenRequest)(nil), "CreateInitialTokenRequest")
|
||||
proto.RegisterType((*CreateInitialTokenResponse)(nil), "CreateInitialTokenResponse")
|
||||
proto.RegisterType((*LoginRequest)(nil), "LoginRequest")
|
||||
proto.RegisterType((*LoginResponse)(nil), "LoginResponse")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// Client API for Hosts service
|
||||
|
||||
type HostsClient interface {
|
||||
AddHost(ctx context.Context, in *AddHostRequest, opts ...grpc.CallOption) (*AddHostResponse, error)
|
||||
RemoveHost(ctx context.Context, in *RemoveHostRequest, opts ...grpc.CallOption) (*RemoveHostResponse, error)
|
||||
GetHost(ctx context.Context, in *GetHostRequest, opts ...grpc.CallOption) (*GetHostResponse, error)
|
||||
}
|
||||
|
||||
type hostsClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewHostsClient(cc *grpc.ClientConn) HostsClient {
|
||||
return &hostsClient{cc}
|
||||
}
|
||||
|
||||
func (c *hostsClient) AddHost(ctx context.Context, in *AddHostRequest, opts ...grpc.CallOption) (*AddHostResponse, error) {
|
||||
out := new(AddHostResponse)
|
||||
err := grpc.Invoke(ctx, "/Hosts/AddHost", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *hostsClient) RemoveHost(ctx context.Context, in *RemoveHostRequest, opts ...grpc.CallOption) (*RemoveHostResponse, error) {
|
||||
out := new(RemoveHostResponse)
|
||||
err := grpc.Invoke(ctx, "/Hosts/RemoveHost", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *hostsClient) GetHost(ctx context.Context, in *GetHostRequest, opts ...grpc.CallOption) (*GetHostResponse, error) {
|
||||
out := new(GetHostResponse)
|
||||
err := grpc.Invoke(ctx, "/Hosts/GetHost", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Hosts service
|
||||
|
||||
type HostsServer interface {
|
||||
AddHost(context.Context, *AddHostRequest) (*AddHostResponse, error)
|
||||
RemoveHost(context.Context, *RemoveHostRequest) (*RemoveHostResponse, error)
|
||||
GetHost(context.Context, *GetHostRequest) (*GetHostResponse, error)
|
||||
}
|
||||
|
||||
func RegisterHostsServer(s *grpc.Server, srv HostsServer) {
|
||||
s.RegisterService(&_Hosts_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Hosts_AddHost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AddHostRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HostsServer).AddHost(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Hosts/AddHost",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HostsServer).AddHost(ctx, req.(*AddHostRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Hosts_RemoveHost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RemoveHostRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HostsServer).RemoveHost(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Hosts/RemoveHost",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HostsServer).RemoveHost(ctx, req.(*RemoveHostRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Hosts_GetHost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetHostRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HostsServer).GetHost(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Hosts/GetHost",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HostsServer).GetHost(ctx, req.(*GetHostRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Hosts_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "Hosts",
|
||||
HandlerType: (*HostsServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "AddHost",
|
||||
Handler: _Hosts_AddHost_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "RemoveHost",
|
||||
Handler: _Hosts_RemoveHost_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetHost",
|
||||
Handler: _Hosts_GetHost_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "route.proto",
|
||||
}
|
||||
|
||||
// Client API for Tokens service
|
||||
|
||||
type TokensClient interface {
|
||||
CreateInitialToken(ctx context.Context, in *CreateInitialTokenRequest, opts ...grpc.CallOption) (*CreateInitialTokenResponse, error)
|
||||
}
|
||||
|
||||
type tokensClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewTokensClient(cc *grpc.ClientConn) TokensClient {
|
||||
return &tokensClient{cc}
|
||||
}
|
||||
|
||||
func (c *tokensClient) CreateInitialToken(ctx context.Context, in *CreateInitialTokenRequest, opts ...grpc.CallOption) (*CreateInitialTokenResponse, error) {
|
||||
out := new(CreateInitialTokenResponse)
|
||||
err := grpc.Invoke(ctx, "/Tokens/CreateInitialToken", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Tokens service
|
||||
|
||||
type TokensServer interface {
|
||||
CreateInitialToken(context.Context, *CreateInitialTokenRequest) (*CreateInitialTokenResponse, error)
|
||||
}
|
||||
|
||||
func RegisterTokensServer(s *grpc.Server, srv TokensServer) {
|
||||
s.RegisterService(&_Tokens_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Tokens_CreateInitialToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateInitialTokenRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TokensServer).CreateInitialToken(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Tokens/CreateInitialToken",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TokensServer).CreateInitialToken(ctx, req.(*CreateInitialTokenRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Tokens_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "Tokens",
|
||||
HandlerType: (*TokensServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CreateInitialToken",
|
||||
Handler: _Tokens_CreateInitialToken_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "route.proto",
|
||||
}
|
||||
|
||||
// Client API for Users service
|
||||
|
||||
type UsersClient interface {
|
||||
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
|
||||
}
|
||||
|
||||
type usersClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewUsersClient(cc *grpc.ClientConn) UsersClient {
|
||||
return &usersClient{cc}
|
||||
}
|
||||
|
||||
func (c *usersClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
|
||||
out := new(LoginResponse)
|
||||
err := grpc.Invoke(ctx, "/Users/Login", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Users service
|
||||
|
||||
type UsersServer interface {
|
||||
Login(context.Context, *LoginRequest) (*LoginResponse, error)
|
||||
}
|
||||
|
||||
func RegisterUsersServer(s *grpc.Server, srv UsersServer) {
|
||||
s.RegisterService(&_Users_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Users_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(LoginRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UsersServer).Login(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Users/Login",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UsersServer).Login(ctx, req.(*LoginRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Users_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "Users",
|
||||
HandlerType: (*UsersServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Login",
|
||||
Handler: _Users_Login_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "route.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("route.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 603 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x54, 0xdd, 0x8a, 0xd3, 0x40,
|
||||
0x14, 0x26, 0xdd, 0x64, 0x7f, 0x4e, 0x7f, 0xf7, 0x28, 0x98, 0x8d, 0x2b, 0x96, 0xf1, 0x87, 0x22,
|
||||
0x32, 0xc1, 0x0a, 0xee, 0xa5, 0xac, 0x0b, 0xda, 0xe2, 0x82, 0x12, 0xf4, 0x01, 0xb2, 0xcd, 0xd0,
|
||||
0xc6, 0xed, 0x66, 0x6a, 0x66, 0x52, 0x58, 0x44, 0x2f, 0x7c, 0x05, 0xdf, 0xc4, 0x57, 0xf1, 0x15,
|
||||
0xbc, 0xf0, 0x31, 0x64, 0xa6, 0x93, 0x34, 0x69, 0xbb, 0x05, 0xf1, 0xaa, 0x73, 0xce, 0x9c, 0x7c,
|
||||
0xdf, 0x39, 0xdf, 0x77, 0xa6, 0x50, 0x4f, 0x79, 0x26, 0x19, 0x9d, 0xa5, 0x5c, 0x72, 0xef, 0x78,
|
||||
0xcc, 0xf9, 0x78, 0xca, 0xfc, 0x70, 0x16, 0xfb, 0x61, 0x92, 0x70, 0x19, 0xca, 0x98, 0x27, 0x62,
|
||||
0x71, 0x4b, 0x1e, 0x40, 0xfd, 0x55, 0x28, 0xd8, 0xe9, 0xfb, 0xe1, 0x59, 0x38, 0x9d, 0xe2, 0x6d,
|
||||
0x70, 0x24, 0xbf, 0x64, 0x89, 0x6b, 0x75, 0xad, 0xde, 0x41, 0xb0, 0x08, 0xc8, 0x4f, 0x0b, 0xec,
|
||||
0x01, 0x17, 0x12, 0x5b, 0x50, 0x8b, 0x23, 0x73, 0x57, 0x8b, 0x23, 0xf4, 0x60, 0x7f, 0xc2, 0x85,
|
||||
0x4c, 0xc2, 0x2b, 0xe6, 0xd6, 0x74, 0xb6, 0x88, 0xf1, 0x21, 0x34, 0x79, 0x12, 0xf3, 0x64, 0x90,
|
||||
0x17, 0xec, 0xe8, 0x82, 0x6a, 0x72, 0x49, 0x68, 0x97, 0x08, 0x15, 0xae, 0x2e, 0x7b, 0xcb, 0xae,
|
||||
0x5d, 0xa7, 0x6b, 0xf5, 0x1a, 0x41, 0x11, 0x23, 0x82, 0x7d, 0x19, 0x27, 0x91, 0xbb, 0xdb, 0xb5,
|
||||
0x7a, 0x4e, 0xa0, 0xcf, 0x2a, 0x37, 0xe3, 0xa9, 0x74, 0xf7, 0x34, 0x88, 0x3e, 0x93, 0x4f, 0xd0,
|
||||
0x3a, 0x8d, 0x22, 0x45, 0x14, 0xb0, 0xcf, 0x19, 0x13, 0x12, 0xbb, 0x60, 0x5f, 0x84, 0x82, 0xe9,
|
||||
0xfe, 0xeb, 0xfd, 0x06, 0x2d, 0x0d, 0x1e, 0xe8, 0x9b, 0xad, 0xf3, 0x94, 0x7b, 0xda, 0xa9, 0xf6,
|
||||
0x44, 0xae, 0xa1, 0x5d, 0x70, 0x89, 0x19, 0x4f, 0x04, 0x5b, 0x93, 0xaa, 0x18, 0xb4, 0xb6, 0x32,
|
||||
0xe8, 0xa4, 0xaa, 0xcf, 0x16, 0x01, 0xed, 0x0d, 0x02, 0x92, 0x21, 0x1c, 0x06, 0xec, 0x8a, 0xcf,
|
||||
0xd9, 0xbf, 0x4d, 0x8a, 0x60, 0x2b, 0x22, 0xd3, 0x8d, 0x3e, 0x13, 0x0a, 0x58, 0x86, 0x32, 0x83,
|
||||
0xb8, 0xb0, 0x27, 0xb2, 0xd1, 0x88, 0x09, 0xa1, 0xe1, 0xf6, 0x83, 0x3c, 0x24, 0x12, 0x5a, 0x6f,
|
||||
0x98, 0xfc, 0x6f, 0x5e, 0x3c, 0x86, 0x83, 0x62, 0x26, 0xa3, 0xc2, 0x32, 0x61, 0x84, 0xb4, 0x73,
|
||||
0x21, 0xc9, 0x53, 0x68, 0x17, 0xac, 0xa6, 0xc5, 0x23, 0x03, 0xba, 0xa0, 0x75, 0xa8, 0xbe, 0x5c,
|
||||
0xcc, 0x74, 0x02, 0x47, 0x67, 0x29, 0x0b, 0x25, 0x1b, 0x26, 0xb1, 0x8c, 0xc3, 0xe9, 0x07, 0x25,
|
||||
0x7b, 0xde, 0xae, 0x07, 0xfb, 0x99, 0x60, 0xa9, 0x16, 0x77, 0xe1, 0x54, 0x11, 0x93, 0x73, 0xf0,
|
||||
0x36, 0x7d, 0x68, 0x18, 0x37, 0xbe, 0x13, 0x25, 0x95, 0x3e, 0xc4, 0x91, 0x99, 0x2f, 0x0f, 0xc9,
|
||||
0x0b, 0x68, 0x9c, 0xf3, 0x71, 0x5c, 0x30, 0x3f, 0x86, 0x16, 0x0f, 0x33, 0x39, 0xe9, 0xcf, 0x52,
|
||||
0x3e, 0x8f, 0x23, 0x96, 0x1a, 0xa0, 0x95, 0x2c, 0x39, 0x81, 0xa6, 0xf9, 0x6e, 0x2b, 0x71, 0x07,
|
||||
0x76, 0xb2, 0x82, 0x54, 0x1d, 0xfb, 0x7f, 0x2c, 0x70, 0x94, 0x0c, 0x02, 0x5f, 0xc3, 0x9e, 0xd9,
|
||||
0x4d, 0x6c, 0xd3, 0xea, 0x8b, 0xf0, 0x3a, 0x74, 0x65, 0x6d, 0x89, 0xfb, 0xfd, 0xd7, 0xef, 0x1f,
|
||||
0x35, 0x24, 0x1d, 0x7f, 0xfe, 0xcc, 0x57, 0x0a, 0x0a, 0x7f, 0xa4, 0x65, 0xc0, 0x77, 0x00, 0xcb,
|
||||
0xed, 0x40, 0xa4, 0x6b, 0x5b, 0xe7, 0xdd, 0xa2, 0xeb, 0xeb, 0x93, 0x03, 0x3e, 0x29, 0x01, 0x7e,
|
||||
0x51, 0x3f, 0x5f, 0x55, 0x63, 0xc6, 0x48, 0x6c, 0xd3, 0xea, 0x22, 0x79, 0x1d, 0xba, 0xe2, 0x71,
|
||||
0x8e, 0x83, 0x6b, 0x38, 0xfd, 0x6f, 0xb0, 0xab, 0xcd, 0x11, 0x28, 0x01, 0xd7, 0x3d, 0x43, 0x8f,
|
||||
0xde, 0xb8, 0x01, 0xde, 0x5d, 0x7a, 0xb3, 0xc9, 0xe4, 0x91, 0xa6, 0xbc, 0x4f, 0xee, 0x29, 0x4a,
|
||||
0x2d, 0x74, 0x2e, 0x46, 0xb9, 0xbc, 0x3f, 0x00, 0xe7, 0xa3, 0x60, 0xa9, 0xc0, 0x97, 0xe0, 0x68,
|
||||
0xb3, 0xb0, 0x49, 0xcb, 0x66, 0x7b, 0x2d, 0x5a, 0xf1, 0x90, 0xdc, 0xd1, 0xb8, 0x87, 0xa4, 0xad,
|
||||
0x70, 0xd5, 0xc2, 0x09, 0x7f, 0xaa, 0x0a, 0x2e, 0x76, 0xf5, 0x7f, 0xf2, 0xf3, 0xbf, 0x01, 0x00,
|
||||
0x00, 0xff, 0xff, 0xd1, 0x7c, 0x6d, 0xec, 0xc0, 0x05, 0x00, 0x00,
|
||||
}
|
|
@ -0,0 +1,420 @@
|
|||
// Code generated by protoc-gen-grpc-gateway
|
||||
// source: route.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package route is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package route
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
)
|
||||
|
||||
var _ codes.Code
|
||||
var _ io.Reader
|
||||
var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
|
||||
var (
|
||||
filter_Hosts_AddHost_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Hosts_AddHost_0(ctx context.Context, marshaler runtime.Marshaler, client HostsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AddHostRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Hosts_AddHost_0); err != nil {
|
||||
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.AddHost(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Hosts_RemoveHost_0 = &utilities.DoubleArray{Encoding: map[string]int{"host": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
|
||||
func request_Hosts_RemoveHost_0(ctx context.Context, marshaler runtime.Marshaler, client HostsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq RemoveHostRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["host"]
|
||||
if !ok {
|
||||
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "host")
|
||||
}
|
||||
|
||||
protoReq.Host, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, err
|
||||
}
|
||||
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Hosts_RemoveHost_0); err != nil {
|
||||
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.RemoveHost(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Hosts_GetHost_0 = &utilities.DoubleArray{Encoding: map[string]int{"host": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
|
||||
)
|
||||
|
||||
func request_Hosts_GetHost_0(ctx context.Context, marshaler runtime.Marshaler, client HostsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq GetHostRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["host"]
|
||||
if !ok {
|
||||
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "host")
|
||||
}
|
||||
|
||||
protoReq.Host, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, err
|
||||
}
|
||||
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Hosts_GetHost_0); err != nil {
|
||||
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.GetHost(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Tokens_CreateInitialToken_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Tokens_CreateInitialToken_0(ctx context.Context, marshaler runtime.Marshaler, client TokensClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CreateInitialTokenRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Tokens_CreateInitialToken_0); err != nil {
|
||||
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.CreateInitialToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Users_Login_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Users_Login_0(ctx context.Context, marshaler runtime.Marshaler, client UsersClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq LoginRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Users_Login_0); err != nil {
|
||||
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterHostsHandlerFromEndpoint is same as RegisterHostsHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterHostsHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterHostsHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterHostsHandler registers the http handlers for service Hosts to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterHostsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
client := NewHostsClient(conn)
|
||||
|
||||
mux.Handle("POST", pattern_Hosts_AddHost_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
if cn, ok := w.(http.CloseNotifier); ok {
|
||||
go func(done <-chan struct{}, closed <-chan bool) {
|
||||
select {
|
||||
case <-done:
|
||||
case <-closed:
|
||||
cancel()
|
||||
}
|
||||
}(ctx.Done(), cn.CloseNotify())
|
||||
}
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
}
|
||||
resp, md, err := request_Hosts_AddHost_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Hosts_AddHost_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("DELETE", pattern_Hosts_RemoveHost_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
if cn, ok := w.(http.CloseNotifier); ok {
|
||||
go func(done <-chan struct{}, closed <-chan bool) {
|
||||
select {
|
||||
case <-done:
|
||||
case <-closed:
|
||||
cancel()
|
||||
}
|
||||
}(ctx.Done(), cn.CloseNotify())
|
||||
}
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
}
|
||||
resp, md, err := request_Hosts_RemoveHost_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Hosts_RemoveHost_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Hosts_GetHost_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
if cn, ok := w.(http.CloseNotifier); ok {
|
||||
go func(done <-chan struct{}, closed <-chan bool) {
|
||||
select {
|
||||
case <-done:
|
||||
case <-closed:
|
||||
cancel()
|
||||
}
|
||||
}(ctx.Done(), cn.CloseNotify())
|
||||
}
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
}
|
||||
resp, md, err := request_Hosts_GetHost_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Hosts_GetHost_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Hosts_AddHost_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "hosts", "create"}, ""))
|
||||
|
||||
pattern_Hosts_RemoveHost_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "hosts", "host"}, ""))
|
||||
|
||||
pattern_Hosts_GetHost_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "hosts", "host"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Hosts_AddHost_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Hosts_RemoveHost_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Hosts_GetHost_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
||||
// RegisterTokensHandlerFromEndpoint is same as RegisterTokensHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterTokensHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterTokensHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterTokensHandler registers the http handlers for service Tokens to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterTokensHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
client := NewTokensClient(conn)
|
||||
|
||||
mux.Handle("POST", pattern_Tokens_CreateInitialToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
if cn, ok := w.(http.CloseNotifier); ok {
|
||||
go func(done <-chan struct{}, closed <-chan bool) {
|
||||
select {
|
||||
case <-done:
|
||||
case <-closed:
|
||||
cancel()
|
||||
}
|
||||
}(ctx.Done(), cn.CloseNotify())
|
||||
}
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
}
|
||||
resp, md, err := request_Tokens_CreateInitialToken_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Tokens_CreateInitialToken_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Tokens_CreateInitialToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "tokens", "createInitialToken"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Tokens_CreateInitialToken_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
||||
// RegisterUsersHandlerFromEndpoint is same as RegisterUsersHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterUsersHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterUsersHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterUsersHandler registers the http handlers for service Users to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterUsersHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
client := NewUsersClient(conn)
|
||||
|
||||
mux.Handle("POST", pattern_Users_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
if cn, ok := w.(http.CloseNotifier); ok {
|
||||
go func(done <-chan struct{}, closed <-chan bool) {
|
||||
select {
|
||||
case <-done:
|
||||
case <-closed:
|
||||
cancel()
|
||||
}
|
||||
}(ctx.Done(), cn.CloseNotify())
|
||||
}
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
}
|
||||
resp, md, err := request_Users_Login_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Users_Login_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Users_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "users", "login"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Users_Login_0 = runtime.ForwardResponseMessage
|
||||
)
|
|
@ -0,0 +1,102 @@
|
|||
syntax = "proto3";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
message BaseAPICall {
|
||||
string token = 1;
|
||||
}
|
||||
|
||||
service Hosts {
|
||||
rpc AddHost(AddHostRequest) returns (AddHostResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/hosts/create"
|
||||
};
|
||||
}
|
||||
rpc RemoveHost(RemoveHostRequest) returns (RemoveHostResponse) {
|
||||
option (google.api.http) = {
|
||||
delete: "/v1/hosts/{host}"
|
||||
};
|
||||
}
|
||||
rpc GetHost(GetHostRequest) returns (GetHostResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/hosts/{host}"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message Host {
|
||||
string id = 1;
|
||||
string hostname = 2;
|
||||
string onionHostname = 3;
|
||||
string token = 4;
|
||||
bytes onionKey = 5;
|
||||
int32 kind = 6;
|
||||
string port = 7;
|
||||
}
|
||||
|
||||
message AddHostRequest {
|
||||
BaseAPICall base = 1;
|
||||
string hostname = 2;
|
||||
bytes onionKey = 3;
|
||||
}
|
||||
|
||||
message AddHostResponse {
|
||||
string id = 1;
|
||||
string token = 2;
|
||||
string hostname = 3;
|
||||
string onionHostname = 4;
|
||||
}
|
||||
|
||||
message RemoveHostRequest {
|
||||
BaseAPICall base = 1;
|
||||
string host = 2;
|
||||
}
|
||||
|
||||
message RemoveHostResponse {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message GetHostRequest {
|
||||
BaseAPICall base = 1;
|
||||
string host = 2;
|
||||
string onionHost = 3;
|
||||
string id = 4;
|
||||
}
|
||||
|
||||
message GetHostResponse {
|
||||
Host host = 1;
|
||||
}
|
||||
|
||||
service Tokens {
|
||||
rpc CreateInitialToken(CreateInitialTokenRequest) returns (CreateInitialTokenResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/tokens/createInitialToken"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message CreateInitialTokenRequest {
|
||||
string username = 1;
|
||||
}
|
||||
|
||||
message CreateInitialTokenResponse {
|
||||
string token = 1;
|
||||
string tokenid = 2;
|
||||
}
|
||||
|
||||
service Users {
|
||||
rpc Login(LoginRequest) returns (LoginResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/users/login"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message LoginRequest {
|
||||
string oauth2provider = 1;
|
||||
}
|
||||
|
||||
message LoginResponse {
|
||||
string token = 1;
|
||||
string uid = 2;
|
||||
}
|
Loading…
Reference in New Issue