api

package
v1.4.8-alpha-2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: MIT Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 `json:"name,omitempty"`
	// Description e.g what's this endpoint for
	Description string `json:"description,omitempty"`
	// API Handler e.g rpc, proxy
	Handler string `json:"handler,omitempty"`
	// HTTP Host e.g example.com
	Host []string `json:"host,omitempty"`
	// HTTP Methods e.g GET, POST
	Method []string `json:"method,omitempty"`
	// HTTP Path e.g /greeter. Expect POSIX regex
	Path []string `json:"path,omitempty"`
	// Body destination
	// "*" or "" - top level message value
	// "string" - inner message value
	Body string `json:"body,omitempty"`
	// Stream flag
	Stream StreamType `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

type Event added in v0.23.0

type Event struct {
	// e.g login
	Name string `json:"name,omitempty"`
	// uuid
	Id string `json:"id,omitempty"`
	// unix timestamp of event
	Timestamp int64 `json:"timestamp,omitempty"`
	// event headers
	Header map[string]*Pair `json:"header,omitempty"`
	// the event data
	Data string `json:"data,omitempty"`
}

Event A HTTP event as RPC Forwarded by the event handler

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) 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

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) 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

type Option

type Option func(*Options) error

type Options

type Options struct{}

type Pair added in v0.23.0

type Pair struct {
	Key    string   `json:"key,omitempty"`
	Values []string `json:"values,omitempty"`
}

type Request added in v0.23.0

type Request struct {
	Method string           `json:"method,omitempty"`
	Path   string           `json:"path,omitempty"`
	Header map[string]*Pair `json:"header,omitempty"`
	Get    map[string]*Pair `json:"get,omitempty"`
	Post   map[string]*Pair `json:"post,omitempty"`
	Body   string           `json:"body,omitempty"`
	Url    string           `json:"url,omitempty"`
}

Request A HTTP request as RPC Forward by the api handler

type Response added in v0.23.0

type Response struct {
	StatusCode int32            `json:"statusCode,omitempty"`
	Header     map[string]*Pair `json:"header,omitempty"`
	Body       string           `json:"body,omitempty"`
}

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

type Service added in v0.23.0

type Service struct {
	// Name of service
	Name string `json:"name,omitempty"`
	// The endpoint for this service
	Endpoint *Endpoint `json:"endpoint,omitempty"`
	// Versions of this service
	Services []*registry.Service `json:"services,omitempty"`
}

Service represents an API service

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