Categorygithub.com/go-micro/plugins/v4/proxy/http
modulepackage
1.2.0
Repository: https://github.com/go-micro/plugins.git
Documentation: pkg.go.dev

# README

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

# Functions

NewService returns a new http proxy.
NewSingleHostRouter returns a router which sends requests a single http backend It is used by setting it in a new micro service to act as a proxy for a http backend.
RegisterEndpoint registers a http endpoint against an RPC endpoint RegisterEndpoint("Foo.Bar", "/foo/bar") RegisterEndpoint("Greeter.Hello", "/helloworld") RegisterEndpoint("Greeter.Hello", "http://localhost:8080/").
WithBackend provides an option to set the http backend url.
WithRouter provides an option to set the http router.

# Variables

DefaultBackend is the default backend address.
DefaultRouter is the default router.

# Structs

Resolver resolves rpc to http.
Router will proxy rpc requests as http POST requests.