http

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRequestId

func BuildRequestId(opts ...utils.Option) gin.HandlerFunc

func Codec added in v1.3.8

func Codec(req *http.Request, name string) (encoding.Codec, bool)

func ErrorEncoder added in v1.3.8

func ErrorEncoder(req *http.Request, rsp http.ResponseWriter, err error)

func GetRequestId

func GetRequestId(ctx *gin.Context) string

func HandleMiddlewares

func HandleMiddlewares(mw ...middleware.Middleware) gin.HandlerFunc

func RequestBodyDecoder added in v1.3.8

func RequestBodyDecoder(req *http.Request, v interface{}) error

func RequestQueryDecoder added in v1.3.8

func RequestQueryDecoder(req *http.Request, v interface{}) error

func RequestVarsDecoder added in v1.3.8

func RequestVarsDecoder(req *http.Request, v interface{}) error

func ResponseEncoder added in v1.3.8

func ResponseEncoder(req *http.Request, rsp http.ResponseWriter, v interface{}) error

func Result

func Result(out proto.Message, err error) gin.HandlerFunc

func SetContentType added in v1.3.8

func SetContentType(subtype string) string

func SubContentType added in v1.3.8

func SubContentType(name string) string

Types

type Client

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

func NewClient

func NewClient(opts ...ClientOption) *Client

func (*Client) DoHTTPReq

func (c *Client) DoHTTPReq(ctx context.Context, req *Request, v interface{}) error

type ClientOption

type ClientOption func(client *Client)

func Timeout

func Timeout(tm time.Duration) ClientOption

func Transport

func Transport(tr *http.Transport) ClientOption

type Codecs added in v1.3.8

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

type Context added in v1.3.8

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

func (*Context) BindBody added in v1.3.8

func (c *Context) BindBody(v interface{}) error

func (*Context) BindQuery added in v1.3.8

func (c *Context) BindQuery(v interface{}) error

func (*Context) BindVars added in v1.3.8

func (c *Context) BindVars(v interface{}) error

func (*Context) Result added in v1.3.8

func (c *Context) Result(code int, v interface{}) error

func (*Context) Set added in v1.3.8

func (c *Context) Set(req *http.Request, rsp http.ResponseWriter)

type Decoder

type Decoder func(ctx context.Context, rsp *http.Response, v interface{}) error

type Encoder

type Encoder func(ctx context.Context, typ string, v interface{}) ([]byte, error)

type EngineParam

type EngineParam struct {
	Mode        string
	BaseUrl     string
	Routers     []func(r gin.IRouter)
	HandlerFunc []gin.HandlerFunc
	http.FileSystem
	logger.Logger
}

type ErrDecoder

type ErrDecoder func(ctx context.Context, response *http.Response) error

type HandlerFunc added in v1.3.8

type HandlerFunc func(ctx *Context) error
type Header struct {
	Code    int         `json:"code"`
	TraceID interface{} `json:"trace_id"`
	Msg     string      `json:"msg"`
}

type Request

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

func NewRequest

func NewRequest() *Request

func (*Request) Decoder

func (r *Request) Decoder(dec Decoder) *Request

func (*Request) Encoder

func (r *Request) Encoder(enc Encoder) *Request

func (*Request) ErrDecoder

func (r *Request) ErrDecoder(errDec ErrDecoder) *Request

func (*Request) Header

func (r *Request) Header(header map[string]string) *Request

func (*Request) Method

func (r *Request) Method(method string) *Request

func (*Request) Param

func (r *Request) Param(param interface{}) *Request

func (*Request) URL

func (r *Request) URL(url string) *Request

type Response added in v1.3.6

type Response struct {
	*Header
	proto.Message `json:"data"`
}

func (Response) Render added in v1.3.6

func (r Response) Render(w http.ResponseWriter) (err error)

func (Response) WriteContentType added in v1.3.6

func (r Response) WriteContentType(w http.ResponseWriter)

type Router added in v1.3.8

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

func NewRouter added in v1.3.8

func NewRouter(srv *Server) *Router

func (*Router) Handle added in v1.3.8

func (r *Router) Handle(method, path string, hf HandlerFunc)

type Server

type Server struct {
	*http.Server

	Engine *gin.Engine
	Codecs *Codecs
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) Route added in v1.3.8

func (s *Server) Route() *Router

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

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

type ServerOption

type ServerOption func(server *Server)

func Address

func Address(addr string) ServerOption

func Engine

func Engine(param *EngineParam) ServerOption

func Handler

func Handler(handler http.Handler) ServerOption

func Handlers

func Handlers(handlers ...middleware.HTTPMiddleware) ServerOption

func Network

func Network(network string) ServerOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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