handler

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

README

Handler

Handler is the interface for handling requests. It defaults to a http.Handler pattern to make life easy.

  • api - Handles any HTTP request. Gives full control over the http request/response via RPC.
  • broker - A http handler which implements the go-micro broker interface
  • cloudevents - Handles CloudEvents and publishes to a message bus.
  • event - Handles any HTTP request and publishes to a message bus.
  • http - Handles any HTTP request and forwards as a reverse proxy.
  • registry - A http handler which implements the go-micro registry interface
  • rpc - Handles json and protobuf POST requests. Forwards as RPC.
  • web - The HTTP handler with web socket support included.

API Handler

The API handler is the default handler. It serves any HTTP requests and forwards on as an RPC request with a specific format.

  • Content-Type: Any
  • Body: Any
  • Forward Format: api.Request/api.Response
  • Path: /[service]/[method]
  • Resolver: Path is used to resolve service and method

Broker Handler

The broker handler is a http handler which serves the go-micro broker interface

  • Content-Type: Any
  • Body: Any
  • Forward Format: HTTP
  • Path: /
  • Resolver: Topic is specified as a query param

Post the request and it will be published

CloudEvents Handler

The CloudEvents handler serves HTTP and forwards the request as a CloudEvents message over a message bus using the go-micro/client.Publish method.

  • Content-Type: Any
  • Body: Any
  • Forward Format: Request is formatted as CloudEvents message
  • Path: /[topic]
  • Resolver: Path is used to resolve topic

Event Handler

The event handler serves HTTP and forwards the request as a message over a message bus using the go-micro/client.Publish method.

  • Content-Type: Any
  • Body: Any
  • Forward Format: Request is formatted as go-api/proto.Event
  • Path: /[topic]/[event]
  • Resolver: Path is used to resolve topic and event name

HTTP Handler

The http handler is a http reserve proxy with built in service discovery.

  • Content-Type: Any
  • Body: Any
  • Forward Format: HTTP Reverse proxy
  • Path: /[service]
  • Resolver: Path is used to resolve service name

Registry Handler

The registry handler is a http handler which serves the go-micro registry interface

  • Content-Type: Any
  • Body: JSON
  • Forward Format: HTTP
  • Path: /
  • Resolver: GET, POST, DELETE used to get service, register or deregister

RPC Handler

The RPC handler serves json or protobuf HTTP POST requests and forwards as an RPC request.

  • Content-Type: application/json or application/protobuf
  • Body: JSON or Protobuf
  • Forward Format: json-rpc or proto-rpc based on content
  • Path: /[service]/[method]
  • Resolver: Path is used to resolve service and method

Web Handler

The web handler is a http reserve proxy with built in service discovery and web socket support.

  • Content-Type: Any
  • Body: Any
  • Forward Format: HTTP Reverse proxy including web sockets
  • Path: /[service]
  • Resolver: Path is used to resolve service name

Documentation

Overview

Package handler provides http handlers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// standard http handler
	http.Handler
	// name of handler
	String() string
}

Handler represents a HTTP handler that manages a request

type Option

type Option func(o *Options)

func WithNamespace

func WithNamespace(s string) Option

WithNamespace specifies the namespace for the handler

func WithRouter

func WithRouter(r router.Router) Option

WithRouter specifies a router to be used by the handler

func WithService

func WithService(s micro.Service) Option

WithService specifies a micro.Service

type Options

type Options struct {
	Namespace string
	Router    router.Router
	Service   micro.Service
}

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions fills in the blanks

Directories

Path Synopsis
Package web contains the web handler including websocket support
Package web contains the web handler including websocket support

Jump to

Keyboard shortcuts

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