http

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodecForResponse

func CodecForResponse(r *http.Response) encoding.Codec

func ContentSubtype

func ContentSubtype(contentType string) string

ContentSubtype returns the content-subtype for the given content-type. The given content-type must be a valid content-type that starts with but no content-subtype will be returned. according rfc7231. contentType is assumed to be lowercase already.

func DefaultErrorDecoder

func DefaultErrorDecoder(ctx context.Context, res *http.Response) error

func DefaultRequestEncoder

func DefaultRequestEncoder(ctx context.Context, contentType string, in interface{}) ([]byte, error)

func DefaultResponseDecoder

func DefaultResponseDecoder(ctx context.Context, res *http.Response, v interface{}) error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

func (*Client) BuildRequest

func (client *Client) BuildRequest(ctx context.Context, method, path, contentType string, args interface{}) (*http.Request, error)

func (*Client) BuildResponse

func (client *Client) BuildResponse(ctx context.Context, res *http.Response, reply interface{}) error

func (*Client) Do

func (client *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) Get

func (client *Client) Get(ctx context.Context, path string, reply interface{}) error

func (*Client) Invoke

func (client *Client) Invoke(ctx context.Context, method, path, contentType string, args interface{}, reply interface{}) error

Invoke makes an rpc call procedure for remote service.

func (*Client) Post

func (client *Client) Post(ctx context.Context, path string, contentType string, args, reply interface{}) error

type ClientOption

type ClientOption func(*clientOptions)

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

func WithErrorDecoder

func WithErrorDecoder(errorDecoder DecodeErrorFunc) ClientOption

func WithRequestEncoder

func WithRequestEncoder(encoder EncodeRequestFunc) ClientOption

func WithResponseDecoder

func WithResponseDecoder(decoder DecodeResponseFunc) ClientOption

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

func WithTlsConfig

func WithTlsConfig(cfg *tls.Config) ClientOption

func WithTransport

func WithTransport(trans *http.Transport) ClientOption

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

type DecodeErrorFunc

type DecodeErrorFunc func(ctx context.Context, res *http.Response) error

type DecodeResponseFunc

type DecodeResponseFunc func(ctx context.Context, res *http.Response, out interface{}) error

type EncodeRequestFunc

type EncodeRequestFunc func(ctx context.Context, contentType string, in interface{}) (body []byte, err error)

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(hs *http.Server, name string) *Server

func (*Server) Close

func (s *Server) Close(ctx context.Context) error

func (*Server) Name

func (s *Server) Name() string

func (*Server) Run

func (s *Server) Run() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL