1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-30 08:06:40 +02:00
go-micro/proxy/proxy.go

32 lines
756 B
Go
Raw Normal View History

2019-06-06 10:50:25 +02:00
// Package proxy is a transparent proxy built on the go-micro/server
package proxy
2019-06-06 18:49:41 +02:00
import (
"context"
"github.com/micro/go-micro/client"
2019-06-12 13:45:42 +02:00
"github.com/micro/go-micro/config/options"
2019-06-06 18:49:41 +02:00
"github.com/micro/go-micro/server"
)
// Proxy can be used as a proxy server for go-micro services
type Proxy interface {
options.Options
// ServeRequest honours the server.Router interface
2019-06-06 18:58:21 +02:00
ServeRequest(context.Context, server.Request, server.Response) error
2019-06-06 18:49:41 +02:00
}
var (
DefaultEndpoint = "localhost:9090"
)
// WithEndpoint sets a proxy endpoint
func WithEndpoint(e string) options.Option {
return options.WithValue("proxy.endpoint", e)
}
// WithClient sets the client
func WithClient(c client.Client) options.Option {
return options.WithValue("proxy.client", c)
}