1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-12 08:23:58 +02:00
go-micro/plugins/proxy/http
2021-11-11 14:03:34 +00:00
..
go.mod upgrade to go 1.17 (#2346) 2021-11-11 14:03:34 +00:00
go.sum upgrade to go 1.17 (#2346) 2021-11-11 14:03:34 +00:00
http_test.go remove unnecessary dependencies between plugins 2021-10-23 16:20:42 +08:00
http.go replace ioutil with io and os (#2327) 2021-10-30 19:24:40 +01:00
options.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
README.md add all the plugins 2020-12-26 15:32:45 +00:00

HTTP Proxy

This is a http proxy plugin which converts RPC to HTTP request

Overview

NewService returns a new http proxy. It acts as a micro service and proxies to a http backend. Routes are dynamically set e.g Foo.Bar routes to /foo/bar. The default backend is http:localhost:9090. Optionally specify the backend endpoint url or the router. Also choose to register specific endpoints.

Usage

service := NewService(
      micro.Name("greeter"),
      // Sets the default http endpoint
      http.WithBackend("http:localhost:10001"),
)

// Set fixed backend endpoints
// register an endpoint
http.RegisterEndpoint("Hello.World", "/helloworld")

service := NewService(
      micro.Name("greeter"),
      // Set the http endpoint
      http.WithBackend("http:localhost:10001"),
)