api

package module
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

README

Go API License GoDoc Travis CI Go Report Card

Go API is a pluggable API framework driven by service discovery to help build powerful public API gateways.

Overview

The Go API library provides api gateway routing capabilities. A microservice architecture decouples application logic into separate service. An api gateway provides a single entry point to consolidate these services into a unified api. The Go API uses routes defined in service discovery metadata to generate routing rules and serve http requests.

Go API

Go API is the basis for the micro api.

Getting Started

See the docs to learn more

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

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

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
broker
Package broker provides a go-micro/broker handler
Package broker provides a go-micro/broker handler
cloudevents
Package cloudevents provides a cloudevents handler publishing the event using the go-micro/client
Package cloudevents provides a cloudevents handler publishing the event using the go-micro/client
event
Package event provides a handler which publishes an event
Package event provides a handler which publishes an event
file
Package file serves file relative to the current directory
Package file serves file relative to the current directory
http
Package http is a http reverse proxy handler
Package http is a http reverse proxy handler
registry
Package registry is a go-micro/registry handler
Package registry is a go-micro/registry handler
rpc
Package rpc is a go-micro rpc handler.
Package rpc is a go-micro rpc handler.
udp
Package udp reads and write from a udp connection
Package udp reads and write from a udp connection
unix
Package unix reads from a unix socket expecting it to be in /tmp/path
Package unix reads from a unix socket expecting it to be in /tmp/path
web
Package web contains the web handler including websocket support
Package web contains the web handler including websocket support
internal
api
Package go_api is a generated protocol buffer package.
Package go_api is a generated protocol buffer package.
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
micro
Package micro provides a micro rpc resolver which prefixes a namespace
Package micro provides a micro rpc resolver which prefixes a namespace
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