api

package
v0.0.0-...-1d97044 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 5 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) *errorAVA.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 APII

type APII interface {
	// Register a http handler
	Register(*Endpoint) *errorAVA.Error
	// Register a route
	Deregister(*Endpoint) *errorAVA.Error
	// Init initialises the command line.
	// It also parses further options.
	//Init(...Option) error
	// Options
	//Options() Options
	// String
	String() string
}

type Endpoint

type Endpoint struct {
	// RPC Method e.g. Greeter.Hello
	Name string
	// Description e.g what's this endpoint for
	Description string
	// API Handler e.g rpc, proxy
	Handler string
	// HTTP Host e.g example.com
	Host []string
	// HTTP Methods e.g GET, POST
	Method []string
	// HTTP 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 map[string]string) *Endpoint

Decode decodes endpoint metadata into an endpoint

type Service

type Service struct {
	// Name of service
	Name string
	// The endpoint for this service
	Endpoint *Endpoint
	// Versions of this service
	Services []*registry.Service
}

Service represents an API service

Jump to

Keyboard shortcuts

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