http

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 17 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 GetRequestId

func GetRequestId(ctx *gin.Context) string

func HandleMiddlewares

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

func Result

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

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 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 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 Server

type Server struct {
	*http.Server

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

func NewServer

func NewServer(opts ...ServerOption) *Server

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