api

package
v3.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

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

type Api interface {
	// Initialise options
	Init(...Option) error
	// Get the options
	Options() Options
	// Register a http handler
	Register(*Endpoint) error
	// Register a route
	Deregister(*Endpoint) error
	// Implementation of api
	String() string
}

Api interface

type Endpoint

type Endpoint struct {
	// Name Greeter.Hello
	Name string
	// Desciption for endpoint
	Description string
	// Handler e.g rpc, proxy
	Handler string
	// Body destination
	// "*" or "" - top level message value
	// "string" - inner message value
	Body string
	// Host e.g example.com
	Host []string
	// Method e.g GET, POST
	Method []string
	// Path e.g /greeter. Expect POSIX regex
	Path []string
	// Stream flag
	Stream bool
}

Endpoint is a mapping between an RPC method and HTTP endpoint

func Decode

func Decode(e metadata.Metadata) *Endpoint

Decode decodes endpoint metadata into an endpoint

type Option

type Option func(*Options) error

Option func signature

type Options

type Options struct{}

Options holds the options

type Service

type Service struct {
	// Name of service
	Name string
	// Endpoint for this service
	Endpoint *Endpoint
	// Services that provides service
	Services []*register.Service
}

Service represents an API service

Directories

Path Synopsis
Package handler provides http handlers
Package handler provides http handlers
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
subdomain
Package subdomain is a resolver which uses the subdomain to determine the domain to route to.
Package subdomain is a resolver which uses the subdomain to determine the domain to route to.
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

Jump to

Keyboard shortcuts

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