Documentation ¶
Overview ¶
Package http provides a micro rpc to http proxy
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // The default backend DefaultBackend = "http://localhost:9090" // The default router DefaultRouter = &Router{} )
Functions ¶
func NewService ¶
func NewService(opts ...micro.Option) micro.Service
NewService returns a new http proxy. It acts as a micro service proxy. Any request on the transport is routed to a fixed http backend.
Usage:
service := NewService( micro.Name("greeter"), // Sets the default http endpoint http.WithBackend("http://localhost:10001"), )
func WithBackend ¶
func WithBackend(url string) micro.Option
WithBackend provides an option to set the http backend url
func WithRouter ¶
WithRouter provides an option to set the http router
Types ¶
type Router ¶
type Router struct { // The http backend to call Backend string // contains filtered or unexported fields }
Router will proxy rpc requests as http POST requests. It is a server.Router
func NewSingleHostRouter ¶
NewSingleHostRouter returns a router which sends requests to a single http backend
It is used by setting it in a new micro service to act as a proxy for a http backend.
Usage:
Create a new router to the http backend
r := NewSingleHostRouter("http://localhost:10001") // Create your new service service := micro.NewService( micro.Name("greeter"), // Set the router http.WithRouter(r), ) // Run the service service.Run()
Click to show internal directories.
Click to hide internal directories.