Documentation ¶
Index ¶
- Constants
- func NewClientContext(ctx context.Context, info ClientInfo) context.Context
- func NewHandler(handler interface{}, opts ...HandleOption) http.Handler
- func NewServerContext(ctx context.Context, info ServerInfo) context.Context
- type CallOption
- type Client
- type ClientInfo
- type ClientOption
- func WithBalancer(b balancer.Balancer) ClientOption
- func WithDiscovery(d registry.Discovery) ClientOption
- func WithEndpoint(endpoint string) ClientOption
- func WithErrorDecoder(errorDecoder DecodeErrorFunc) ClientOption
- func WithMiddleware(m ...middleware.Middleware) ClientOption
- func WithRequestEncoder(encoder EncodeRequestFunc) ClientOption
- func WithResponseDecoder(decoder DecodeResponseFunc) ClientOption
- func WithScheme(scheme string) ClientOption
- func WithTimeout(d time.Duration) ClientOption
- func WithTransport(trans http.RoundTripper) ClientOption
- func WithUserAgent(ua string) ClientOption
- type DecodeErrorFunc
- type DecodeRequestFunc
- type DecodeResponseFunc
- type EmptyCallOption
- type EncodeErrorFunc
- type EncodeRequestFunc
- type EncodeResponseFunc
- type HandleOption
- type HandleOptions
- type Handler
- type MethodCallOption
- type PathPatternCallOption
- type Server
- func (s *Server) Endpoint() (string, error)
- func (s *Server) Handle(path string, h http.Handler)
- func (s *Server) HandleFunc(path string, h http.HandlerFunc)
- func (s *Server) HandlePrefix(prefix string, h http.Handler)
- func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request)
- func (s *Server) Start() error
- func (s *Server) Stop() error
- type ServerInfo
- type ServerOption
- type Target
Constants ¶
const SupportPackageIsVersion1 = true
SupportPackageIsVersion1 These constants should not be referenced from any other code.
Variables ¶
This section is empty.
Functions ¶
func NewClientContext ¶
func NewClientContext(ctx context.Context, info ClientInfo) context.Context
NewClientContext returns a new Context that carries value.
func NewHandler ¶
func NewHandler(handler interface{}, opts ...HandleOption) http.Handler
NewHandler new a HTTP handler.
func NewServerContext ¶
func NewServerContext(ctx context.Context, info ServerInfo) context.Context
NewServerContext returns a new Context that carries value.
Types ¶
type CallOption ¶
type CallOption interface {
// contains filtered or unexported methods
}
CallOption configures a Call before it starts or extracts information from a Call after it completes.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is http client
func NewClient ¶
func NewClient(ctx context.Context, opts ...ClientOption) (*Client, error)
NewClient returns an HTTP client.
type ClientInfo ¶
ClientInfo represent HTTP client information.
func FromClientContext ¶
func FromClientContext(ctx context.Context) (info ClientInfo, ok bool)
FromClientContext returns the Transport value stored in ctx, if any.
type ClientOption ¶
type ClientOption func(*clientOptions)
ClientOption is HTTP client option.
func WithBalancer ¶
func WithBalancer(b balancer.Balancer) ClientOption
WithBalancer with client balancer. Experimental Notice: This type is EXPERIMENTAL and may be changed or removed in a later release.
func WithDiscovery ¶
func WithDiscovery(d registry.Discovery) ClientOption
WithDiscovery with client discovery.
func WithErrorDecoder ¶
func WithErrorDecoder(errorDecoder DecodeErrorFunc) ClientOption
WithErrorDecoder with client error decoder.
func WithMiddleware ¶
func WithMiddleware(m ...middleware.Middleware) ClientOption
WithMiddleware with client middleware.
func WithRequestEncoder ¶
func WithRequestEncoder(encoder EncodeRequestFunc) ClientOption
WithRequestEncoder with client request encoder.
func WithResponseDecoder ¶
func WithResponseDecoder(decoder DecodeResponseFunc) ClientOption
WithResponseDecoder with client response decoder.
func WithTimeout ¶
func WithTimeout(d time.Duration) ClientOption
WithTimeout with client request timeout.
func WithTransport ¶
func WithTransport(trans http.RoundTripper) ClientOption
WithTransport with client transport.
func WithUserAgent ¶
func WithUserAgent(ua string) ClientOption
WithUserAgent with client user agent.
type DecodeErrorFunc ¶
DecodeErrorFunc is decode error func.
type DecodeRequestFunc ¶
DecodeRequestFunc is decode request func.
type DecodeResponseFunc ¶
DecodeResponseFunc is response decode func.
type EmptyCallOption ¶
type EmptyCallOption struct{}
EmptyCallOption does not alter the Call configuration. It can be embedded in another structure to carry satellite data for use by interceptors.
type EncodeErrorFunc ¶
type EncodeErrorFunc func(http.ResponseWriter, *http.Request, error)
EncodeErrorFunc is encode error func.
type EncodeRequestFunc ¶
type EncodeRequestFunc func(ctx context.Context, in interface{}) (contentType string, body []byte, err error)
EncodeRequestFunc is request encode func.
type EncodeResponseFunc ¶
type EncodeResponseFunc func(http.ResponseWriter, *http.Request, interface{}) error
EncodeResponseFunc is encode response func.
type HandleOption ¶
type HandleOption func(*HandleOptions)
HandleOption is handle option.
func ErrorEncoder ¶
func ErrorEncoder(en EncodeErrorFunc) HandleOption
ErrorEncoder with error encoder.
func Middleware ¶
func Middleware(m ...middleware.Middleware) HandleOption
Middleware with middleware option.
func RequestDecoder ¶
func RequestDecoder(dec DecodeRequestFunc) HandleOption
RequestDecoder with request decoder.
func ResponseEncoder ¶
func ResponseEncoder(en EncodeResponseFunc) HandleOption
ResponseEncoder with response encoder.
type HandleOptions ¶
type HandleOptions struct { Decode DecodeRequestFunc Encode EncodeResponseFunc Error EncodeErrorFunc Middleware middleware.Middleware }
HandleOptions is handle options. Deprecated: use Handler instead.
func DefaultHandleOptions ¶
func DefaultHandleOptions() HandleOptions
DefaultHandleOptions returns a default handle options. Deprecated: use NewHandler instead.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is handle options.
type MethodCallOption ¶
type MethodCallOption struct { EmptyCallOption Method string }
MethodCallOption is BodyCallOption
type PathPatternCallOption ¶
type PathPatternCallOption struct { EmptyCallOption PathPattern string }
PathPatternCallOption is BodyPattern
type Server ¶
Server is a HTTP server wrapper.
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
NewServer creates a HTTP server by options.
func (*Server) Endpoint ¶
Endpoint return a real address to registry endpoint. examples:
http://127.0.0.1:8000?isSecure=false
func (*Server) HandleFunc ¶
func (s *Server) HandleFunc(path string, h http.HandlerFunc)
HandleFunc registers a new route with a matcher for the URL path.
func (*Server) HandlePrefix ¶
HandlePrefix registers a new route with a matcher for the URL path prefix.
type ServerInfo ¶
type ServerInfo struct { Request *http.Request Response http.ResponseWriter }
ServerInfo represent HTTP server information.
func FromServerContext ¶
func FromServerContext(ctx context.Context) (info ServerInfo, ok bool)
FromServerContext returns the Transport value stored in ctx, if any.