go-api: github.com/micro/go-api Index | Files | Directories

package api

import "github.com/micro/go-api"

Index

Package Files

api.go

func Encode Uses

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

Encode encodes an endpoint to endpoint metadata

func Validate Uses

func Validate(e *Endpoint) error

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

func WithEndpoint Uses

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"},
	},
))

type Endpoint Uses

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
}

Endpoint is a mapping between an RPC method and HTTP endpoint

func Decode Uses

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

Decode decodes endpoint metadata into an endpoint

type Service Uses

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

Directories

PathSynopsis
handlerPackage handler provides http handlers
handler/apiPackage api provides an http-rpc handler which provides the entire http request over rpc
handler/brokerPackage broker provides a go-micro/broker handler
handler/cloudeventsPackage cloudevents provides a cloudevents handler publishing the event using the go-micro/client
handler/eventPackage event provides a handler which publishes an event
handler/filePackage file serves file relative to the current directory
handler/httpPackage http is a http reverse proxy handler
handler/registryPackage registry is a go-micro/registry handler
handler/rpcPackage rpc is a go-micro rpc handler.
handler/udpPackage udp reads and write from a udp connection
handler/unixPackage unix reads from a unix socket expecting it to be in /tmp/path
handler/webPackage web contains the web handler including websocket support
internal/proto
protoPackage go_api is a generated protocol buffer package.
resolverPackage resolver resolves a http request to an endpoint
resolver/grpcPackage grpc resolves a grpc service like /greeter.Say/Hello to greeter service
resolver/hostPackage host resolves using http host
resolver/microPackage micro provides a micro rpc resolver which prefixes a namespace
resolver/pathPackage path resolves using http path
resolver/vpathPackage vpath resolves using http path and recognised versioned urls
routerPackage router provides api service routing
serverPackage server provides a http server with features; acme, cors, etc

Package api imports 5 packages (graph) and is imported by 9 packages. Updated 2019-02-15. Refresh now. Tools for package owners.