api

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthApi        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowApi          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupApi = fmt.Errorf("proto: unexpected end of group")
)

Functions

func Encode

func Encode(e *Endpoint) map[string]string

Encode encodes an endpoint to endpoint metadata

func Validate

func Validate(e *Endpoint) error

Validate validates an endpoint to guarantee it won't blow up when being served

func WithEndpoint

func WithEndpoint(e *Endpoint) server.HandlerOption

WithEndpoint returns a server.HandlerOption with endpoint metadata set

Usage:

proto.RegisterHandler(service.Server(), new(Handler), api.WithEndpoint(
	&api.Endpoint{
		Name: "Greeter.Hello",
		Path: []string{"/greeter"},
	},
))

Types

type API added in v1.4.1

type API interface {
	// Init initialise options
	Init(...Option) error
	// Options Get the options
	Options() Options
	// Register a http handler
	Register(*Endpoint) error
	// Deregister unregister a route
	Deregister(*Endpoint) error
	// String implementation of api
	String() string
}

type Endpoint added in v0.23.0

type Endpoint struct {
	// RPC Method e.g. Greeter.Hello
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Description e.g what's this endpoint for
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// API Handler e.g rpc, proxy
	Handler string `protobuf:"bytes,3,opt,name=handler,proto3" json:"handler,omitempty"`
	// HTTP Host e.g example.com
	Host []string `protobuf:"bytes,4,rep,name=host,proto3" json:"host,omitempty"`
	// HTTP Methods e.g GET, POST
	Method []string `protobuf:"bytes,5,rep,name=method,proto3" json:"method,omitempty"`
	// HTTP Path e.g /greeter. Expect POSIX regex
	Path []string `protobuf:"bytes,6,rep,name=path,proto3" json:"path,omitempty"`
	// Entity HTTP method for resource
	Entity string `protobuf:"bytes,7,opt,name=entity,proto3" json:"entity,omitempty"`
	// Security HTTP authorization, e.g. Basic, Bearer
	Security string `protobuf:"bytes,8,opt,name=security,proto3" json:"security,omitempty"`
	// Body destination
	// "*" or "" - top level message value
	// "string" - inner message value
	Body string `protobuf:"bytes,9,opt,name=body,proto3" json:"body,omitempty"`
	// Stream flag
	Stream string `protobuf:"bytes,10,opt,name=stream,proto3" json:"stream,omitempty"`
}

Endpoint is a mapping between an RPC method and HTTP endpoint

func Decode

func Decode(e map[string]string) *Endpoint

Decode decodes endpoint metadata into an endpoint

func (*Endpoint) DeepCopyInto added in v1.5.6

func (in *Endpoint) DeepCopyInto(out *Endpoint)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Endpoint) Descriptor added in v1.5.6

func (*Endpoint) Descriptor() ([]byte, []int)

func (*Endpoint) Marshal added in v1.5.6

func (m *Endpoint) Marshal() (dAtA []byte, err error)

func (*Endpoint) MarshalTo added in v1.5.6

func (m *Endpoint) MarshalTo(dAtA []byte) (int, error)

func (*Endpoint) MarshalToSizedBuffer added in v1.5.6

func (m *Endpoint) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Endpoint) ProtoMessage added in v1.5.6

func (*Endpoint) ProtoMessage()

func (*Endpoint) Reset added in v1.5.6

func (m *Endpoint) Reset()

func (*Endpoint) String added in v1.5.6

func (m *Endpoint) String() string

func (*Endpoint) Unmarshal added in v1.5.6

func (m *Endpoint) Unmarshal(dAtA []byte) error

func (*Endpoint) XSize added in v1.5.6

func (m *Endpoint) XSize() (n int)

func (*Endpoint) XXX_DiscardUnknown added in v1.5.6

func (m *Endpoint) XXX_DiscardUnknown()

func (*Endpoint) XXX_Marshal added in v1.5.6

func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Endpoint) XXX_Merge added in v1.5.6

func (m *Endpoint) XXX_Merge(src proto.Message)

func (*Endpoint) XXX_Size added in v1.5.6

func (m *Endpoint) XXX_Size() int

func (*Endpoint) XXX_Unmarshal added in v1.5.6

func (m *Endpoint) XXX_Unmarshal(b []byte) error

type Event added in v0.23.0

type Event struct {
	// e.g login
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// uuid
	Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	// unix timestamp of event
	Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// event headers
	Header map[string]*Pair `` /* 153-byte string literal not displayed */
	// the event data
	Data string `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
}

Event A HTTP event as RPC Forwarded by the event handler

func (*Event) DeepCopyInto added in v1.5.6

func (in *Event) DeepCopyInto(out *Event)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Event) Descriptor added in v1.5.6

func (*Event) Descriptor() ([]byte, []int)

func (*Event) Marshal added in v1.5.6

func (m *Event) Marshal() (dAtA []byte, err error)

func (*Event) MarshalTo added in v1.5.6

func (m *Event) MarshalTo(dAtA []byte) (int, error)

func (*Event) MarshalToSizedBuffer added in v1.5.6

func (m *Event) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Event) ProtoMessage added in v1.5.3

func (*Event) ProtoMessage()

func (*Event) Reset added in v1.5.3

func (m *Event) Reset()

func (*Event) String added in v1.5.3

func (m *Event) String() string

func (*Event) Unmarshal added in v1.5.6

func (m *Event) Unmarshal(dAtA []byte) error

func (*Event) XSize added in v1.5.6

func (m *Event) XSize() (n int)

func (*Event) XXX_DiscardUnknown added in v1.5.6

func (m *Event) XXX_DiscardUnknown()

func (*Event) XXX_Marshal added in v1.5.6

func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Event) XXX_Merge added in v1.5.6

func (m *Event) XXX_Merge(src proto.Message)

func (*Event) XXX_Size added in v1.5.6

func (m *Event) XXX_Size() int

func (*Event) XXX_Unmarshal added in v1.5.6

func (m *Event) XXX_Unmarshal(b []byte) error

type FileDesc added in v1.4.0

type FileDesc struct {
	// 文件名称
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// 读取偏离量
	Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
}

func (*FileDesc) DeepCopyInto added in v1.5.6

func (in *FileDesc) DeepCopyInto(out *FileDesc)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*FileDesc) Descriptor added in v1.5.6

func (*FileDesc) Descriptor() ([]byte, []int)

func (*FileDesc) Marshal added in v1.5.6

func (m *FileDesc) Marshal() (dAtA []byte, err error)

func (*FileDesc) MarshalTo added in v1.5.6

func (m *FileDesc) MarshalTo(dAtA []byte) (int, error)

func (*FileDesc) MarshalToSizedBuffer added in v1.5.6

func (m *FileDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*FileDesc) ProtoMessage added in v1.4.0

func (*FileDesc) ProtoMessage()

func (*FileDesc) Reset added in v1.4.0

func (m *FileDesc) Reset()

func (*FileDesc) String added in v1.4.0

func (m *FileDesc) String() string

func (*FileDesc) Unmarshal added in v1.5.6

func (m *FileDesc) Unmarshal(dAtA []byte) error

func (*FileDesc) XSize added in v1.5.6

func (m *FileDesc) XSize() (n int)

func (*FileDesc) XXX_DiscardUnknown added in v1.5.6

func (m *FileDesc) XXX_DiscardUnknown()

func (*FileDesc) XXX_Marshal added in v1.5.6

func (m *FileDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FileDesc) XXX_Merge added in v1.5.6

func (m *FileDesc) XXX_Merge(src proto.Message)

func (*FileDesc) XXX_Size added in v1.5.6

func (m *FileDesc) XXX_Size() int

func (*FileDesc) XXX_Unmarshal added in v1.5.6

func (m *FileDesc) XXX_Unmarshal(b []byte) error

type FileHeader added in v1.4.0

type FileHeader struct {
	Name   string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Size   int64  `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
	Length int64  `protobuf:"varint,3,opt,name=length,proto3" json:"length,omitempty"`
	Chunk  []byte `protobuf:"bytes,4,opt,name=chunk,proto3" json:"chunk,omitempty"`
}

func (*FileHeader) DeepCopyInto added in v1.5.6

func (in *FileHeader) DeepCopyInto(out *FileHeader)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*FileHeader) Descriptor added in v1.5.6

func (*FileHeader) Descriptor() ([]byte, []int)

func (*FileHeader) Marshal added in v1.5.6

func (m *FileHeader) Marshal() (dAtA []byte, err error)

func (*FileHeader) MarshalTo added in v1.5.6

func (m *FileHeader) MarshalTo(dAtA []byte) (int, error)

func (*FileHeader) MarshalToSizedBuffer added in v1.5.6

func (m *FileHeader) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*FileHeader) ProtoMessage added in v1.4.0

func (*FileHeader) ProtoMessage()

func (*FileHeader) Reset added in v1.4.0

func (m *FileHeader) Reset()

func (*FileHeader) String added in v1.4.0

func (m *FileHeader) String() string

func (*FileHeader) Unmarshal added in v1.5.6

func (m *FileHeader) Unmarshal(dAtA []byte) error

func (*FileHeader) XSize added in v1.5.6

func (m *FileHeader) XSize() (n int)

func (*FileHeader) XXX_DiscardUnknown added in v1.5.6

func (m *FileHeader) XXX_DiscardUnknown()

func (*FileHeader) XXX_Marshal added in v1.5.6

func (m *FileHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FileHeader) XXX_Merge added in v1.5.6

func (m *FileHeader) XXX_Merge(src proto.Message)

func (*FileHeader) XXX_Size added in v1.5.6

func (m *FileHeader) XXX_Size() int

func (*FileHeader) XXX_Unmarshal added in v1.5.6

func (m *FileHeader) XXX_Unmarshal(b []byte) error

type Option

type Option func(*Options) error

type Options

type Options struct{}

type Pair added in v0.23.0

type Pair struct {
	Key    string   `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"`
}

func (*Pair) DeepCopyInto added in v1.5.6

func (in *Pair) DeepCopyInto(out *Pair)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Pair) Descriptor added in v1.5.6

func (*Pair) Descriptor() ([]byte, []int)

func (*Pair) Marshal added in v1.5.6

func (m *Pair) Marshal() (dAtA []byte, err error)

func (*Pair) MarshalTo added in v1.5.6

func (m *Pair) MarshalTo(dAtA []byte) (int, error)

func (*Pair) MarshalToSizedBuffer added in v1.5.6

func (m *Pair) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Pair) ProtoMessage added in v1.5.6

func (*Pair) ProtoMessage()

func (*Pair) Reset added in v1.5.6

func (m *Pair) Reset()

func (*Pair) String added in v1.5.6

func (m *Pair) String() string

func (*Pair) Unmarshal added in v1.5.6

func (m *Pair) Unmarshal(dAtA []byte) error

func (*Pair) XSize added in v1.5.6

func (m *Pair) XSize() (n int)

func (*Pair) XXX_DiscardUnknown added in v1.5.6

func (m *Pair) XXX_DiscardUnknown()

func (*Pair) XXX_Marshal added in v1.5.6

func (m *Pair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Pair) XXX_Merge added in v1.5.6

func (m *Pair) XXX_Merge(src proto.Message)

func (*Pair) XXX_Size added in v1.5.6

func (m *Pair) XXX_Size() int

func (*Pair) XXX_Unmarshal added in v1.5.6

func (m *Pair) XXX_Unmarshal(b []byte) error

type Request added in v0.23.0

type Request struct {
	Method string           `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
	Path   string           `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
	Header map[string]*Pair `` /* 153-byte string literal not displayed */
	Get    map[string]*Pair `` /* 147-byte string literal not displayed */
	Post   map[string]*Pair `` /* 149-byte string literal not displayed */
	Body   string           `protobuf:"bytes,6,opt,name=body,proto3" json:"body,omitempty"`
	Url    string           `protobuf:"bytes,7,opt,name=url,proto3" json:"url,omitempty"`
}

Request A HTTP request as RPC Forward by the api handler +gogo:genproto=true

func (*Request) DeepCopyInto added in v1.5.6

func (in *Request) DeepCopyInto(out *Request)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Request) Descriptor added in v1.5.6

func (*Request) Descriptor() ([]byte, []int)

func (*Request) Marshal added in v1.5.6

func (m *Request) Marshal() (dAtA []byte, err error)

func (*Request) MarshalTo added in v1.5.6

func (m *Request) MarshalTo(dAtA []byte) (int, error)

func (*Request) MarshalToSizedBuffer added in v1.5.6

func (m *Request) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Request) ProtoMessage added in v1.5.6

func (*Request) ProtoMessage()

func (*Request) Reset added in v1.5.6

func (m *Request) Reset()

func (*Request) String added in v1.5.6

func (m *Request) String() string

func (*Request) Unmarshal added in v1.5.6

func (m *Request) Unmarshal(dAtA []byte) error

func (*Request) XSize added in v1.5.6

func (m *Request) XSize() (n int)

func (*Request) XXX_DiscardUnknown added in v1.5.6

func (m *Request) XXX_DiscardUnknown()

func (*Request) XXX_Marshal added in v1.5.6

func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Request) XXX_Merge added in v1.5.6

func (m *Request) XXX_Merge(src proto.Message)

func (*Request) XXX_Size added in v1.5.6

func (m *Request) XXX_Size() int

func (*Request) XXX_Unmarshal added in v1.5.6

func (m *Request) XXX_Unmarshal(b []byte) error

type Response added in v0.23.0

type Response struct {
	StatusCode int32            `protobuf:"varint,1,opt,name=statusCode,proto3" json:"statusCode,omitempty"`
	Header     map[string]*Pair `` /* 153-byte string literal not displayed */
	Body       string           `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
}

Response A HTTP response as RPC Expected response for the api handler

func (*Response) DeepCopyInto added in v1.5.6

func (in *Response) DeepCopyInto(out *Response)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Response) Descriptor added in v1.5.6

func (*Response) Descriptor() ([]byte, []int)

func (*Response) Marshal added in v1.5.6

func (m *Response) Marshal() (dAtA []byte, err error)

func (*Response) MarshalTo added in v1.5.6

func (m *Response) MarshalTo(dAtA []byte) (int, error)

func (*Response) MarshalToSizedBuffer added in v1.5.6

func (m *Response) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Response) ProtoMessage added in v1.5.6

func (*Response) ProtoMessage()

func (*Response) Reset added in v1.5.6

func (m *Response) Reset()

func (*Response) String added in v1.5.6

func (m *Response) String() string

func (*Response) Unmarshal added in v1.5.6

func (m *Response) Unmarshal(dAtA []byte) error

func (*Response) XSize added in v1.5.6

func (m *Response) XSize() (n int)

func (*Response) XXX_DiscardUnknown added in v1.5.6

func (m *Response) XXX_DiscardUnknown()

func (*Response) XXX_Marshal added in v1.5.6

func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Response) XXX_Merge added in v1.5.6

func (m *Response) XXX_Merge(src proto.Message)

func (*Response) XXX_Size added in v1.5.6

func (m *Response) XXX_Size() int

func (*Response) XXX_Unmarshal added in v1.5.6

func (m *Response) XXX_Unmarshal(b []byte) error

type Service added in v0.23.0

type Service struct {
	// Name of service
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The endpoint for this service
	Endpoint *Endpoint `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
	// Versions of this service
	Services []*registry.Service `protobuf:"bytes,3,rep,name=services,proto3" json:"services,omitempty"`
}

Service represents an API service

func (*Service) DeepCopyInto added in v1.5.6

func (in *Service) DeepCopyInto(out *Service)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Service) Descriptor added in v1.5.6

func (*Service) Descriptor() ([]byte, []int)

func (*Service) Marshal added in v1.5.6

func (m *Service) Marshal() (dAtA []byte, err error)

func (*Service) MarshalTo added in v1.5.6

func (m *Service) MarshalTo(dAtA []byte) (int, error)

func (*Service) MarshalToSizedBuffer added in v1.5.6

func (m *Service) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Service) ProtoMessage added in v1.5.6

func (*Service) ProtoMessage()

func (*Service) Reset added in v1.5.6

func (m *Service) Reset()

func (*Service) String added in v1.5.6

func (m *Service) String() string

func (*Service) Unmarshal added in v1.5.6

func (m *Service) Unmarshal(dAtA []byte) error

func (*Service) XSize added in v1.5.6

func (m *Service) XSize() (n int)

func (*Service) XXX_DiscardUnknown added in v1.5.6

func (m *Service) XXX_DiscardUnknown()

func (*Service) XXX_Marshal added in v1.5.6

func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Service) XXX_Merge added in v1.5.6

func (m *Service) XXX_Merge(src proto.Message)

func (*Service) XXX_Size added in v1.5.6

func (m *Service) XXX_Size() int

func (*Service) XXX_Unmarshal added in v1.5.6

func (m *Service) XXX_Unmarshal(b []byte) error

type StreamType added in v1.4.0

type StreamType string
const (
	Server        StreamType = "server"
	Client        StreamType = "client"
	Bidirectional StreamType = "bidirectional"
)

Directories

Path Synopsis
Package handler provides http handlers
Package handler provides http handlers
api
Package api provides an http-rpc handler which provides the entire http request over rpc
Package api provides an http-rpc handler which provides the entire http request over rpc
event
Package event provides a handler which publishes an event
Package event provides a handler which publishes an event
http
Package http is a http reverse proxy handler
Package http is a http reverse proxy handler
rpc
Package rpc is a vine rpc handler.
Package rpc is a vine rpc handler.
web
Package web contains the web handler including websocket support
Package web contains the web handler including websocket support
Package resolver resolves a http request to an endpoint
Package resolver resolves a http request to an endpoint
grpc
Package grpc resolves a grpc service like /greeter.Say/Hello to greeter service
Package grpc resolves a grpc service like /greeter.Say/Hello to greeter service
host
Package host resolves using http host
Package host resolves using http host
path
Package path resolves using http path
Package path resolves using http path
vpath
Package vpath resolves using http path and recognised versioned urls
Package vpath resolves using http path and recognised versioned urls
Package router provides api service routing
Package router provides api service routing
registry
Package registry provides a dynamic api service router
Package registry provides a dynamic api service router
Package server provides an API gateway server which handles inbound requests
Package server provides an API gateway server which handles inbound requests
http
Package http provides a http server with features; acme, cors, etc
Package http provides a http server with features; acme, cors, etc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL