http

package
v0.0.0-...-9eed78a Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceKeyQuery   = "_query_string"
	TraceKeyReq     = "_request"
	TraceKeyReqBody = "_request_body"
	TraceKeyRsp     = "_response"

	RspCtxKey = "_rsp_ctx_key"
)

Variables

This section is empty.

Functions

func Cors

func Cors(opts ...CORSOption) gin.HandlerFunc

func InjectRspToContext

func InjectRspToContext(c *gin.Context, rsp string)

func MetricInterceptor

func MetricInterceptor() gin.HandlerFunc

func OpentracingInterceptor

func OpentracingInterceptor() gin.HandlerFunc

func RequestFromServerContext

func RequestFromServerContext(ctx context.Context) (*http.Request, bool)

func RspFromContext

func RspFromContext(c *gin.Context) string

func SetCookie

func SetCookie(ctx context.Context, cookie *http.Cookie)

func SetOperation

func SetOperation(ctx context.Context, op string)

Types

type CORSOption

type CORSOption func(*corsOptions)

func AllowAllOrigins

func AllowAllOrigins() CORSOption

func AllowBrowserExtensions

func AllowBrowserExtensions() CORSOption

func AllowCredentials

func AllowCredentials() CORSOption

func AllowFiles

func AllowFiles() CORSOption

func AllowHeaders

func AllowHeaders(h ...string) CORSOption

func AllowMethods

func AllowMethods(m ...string) CORSOption

func AllowOriginFunc

func AllowOriginFunc(f func(string) bool) CORSOption

func AllowOriginWithContextFunc

func AllowOriginWithContextFunc(f func(c *gin.Context, origin string) bool) CORSOption

func AllowOrigins

func AllowOrigins(args ...string) CORSOption

func AllowPrivateNetwork

func AllowPrivateNetwork() CORSOption

func AllowWebSockets

func AllowWebSockets() CORSOption

func AllowWildcard

func AllowWildcard() CORSOption

func CustomSchemas

func CustomSchemas(schemas ...string) CORSOption

func ExposeHeaders

func ExposeHeaders(h ...string) CORSOption

func MaxAge

func MaxAge(t time.Duration) CORSOption

func OptionsResponseStatusCode

func OptionsResponseStatusCode(statusCode int) CORSOption

type EngineCustomizer

type EngineCustomizer func(*gin.Engine)

type Server

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

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) Customize

func (s *Server) Customize(loader EngineCustomizer)

func (*Server) DELETE

func (s *Server) DELETE(relativePath string, handlers ...gin.HandlerFunc)

DELETE is a shortcut for router.Handle("DELETE", path, handlers).

func (*Server) Endpoint

func (s *Server) Endpoint() (*url.URL, error)

func (*Server) GET

func (s *Server) GET(relativePath string, handlers ...gin.HandlerFunc)

GET is a shortcut for router.Handle("GET", path, handlers).

func (*Server) HEAD

func (s *Server) HEAD(relativePath string, handlers ...gin.HandlerFunc)

HEAD is a shortcut for router.Handle("HEAD", path, handlers).

func (*Server) Handle

func (s *Server) Handle(httpMethod, relativePath string, handlers ...gin.HandlerFunc)

Handle registers a new request handle and middleware with the given path and method. The last handler should be the real handler, the other ones should be middleware that can and should be shared among different routes. See the example code in GitHub.

For GET, POST, PUT, PATCH and DELETE requests the respective shortcut functions can be used.

This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for internal communication with a proxy).

func (*Server) HandleAny

func (s *Server) HandleAny(relativePath string, handlers ...gin.HandlerFunc)

HandleAny registers a route that matches all the HTTP methods. GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, CONNECT, TRACE.

func (*Server) Match

func (s *Server) Match(methods []string, relativePath string, handlers ...gin.HandlerFunc)

Match registers a route that matches the specified methods that you declared.

func (*Server) OPTIONS

func (s *Server) OPTIONS(relativePath string, handlers ...gin.HandlerFunc)

OPTIONS is a shortcut for router.Handle("OPTIONS", path, handlers).

func (*Server) PATCH

func (s *Server) PATCH(relativePath string, handlers ...gin.HandlerFunc)

PATCH is a shortcut for router.Handle("PATCH", path, handlers).

func (*Server) POST

func (s *Server) POST(relativePath string, handlers ...gin.HandlerFunc)

POST is a shortcut for router.Handle("POST", path, handlers).

func (*Server) PUT

func (s *Server) PUT(relativePath string, handlers ...gin.HandlerFunc)

PUT is a shortcut for router.Handle("PUT", path, handlers).

func (*Server) Start

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

func (*Server) Stop

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

func (*Server) Use

func (s *Server) Use(fn gin.HandlerFunc)

type ServerOption

type ServerOption func(*Server)

func Address

func Address(address string) ServerOption

func Debug

func Debug() ServerOption

func Endpoint

func Endpoint(endpoint *url.URL) ServerOption

func Env

func Env(env string) ServerOption

func Listener

func Listener(lis net.Listener) ServerOption

func Middlewares

func Middlewares(fns ...gin.HandlerFunc) ServerOption

func Network

func Network(network string) ServerOption

func ReadTimeout

func ReadTimeout(t time.Duration) ServerOption

func ServiceName

func ServiceName(name string) ServerOption

func TLSConfig

func TLSConfig(c *tls.Config) ServerOption

func Timeout

func Timeout(t time.Duration) ServerOption

func WriteTimeout

func WriteTimeout(t time.Duration) ServerOption

type Transport

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

func (*Transport) Endpoint

func (tr *Transport) Endpoint() string

func (*Transport) G

func (tr *Transport) G() *gin.Context

func (*Transport) Kind

func (tr *Transport) Kind() transport.Kind

func (*Transport) Operation

func (tr *Transport) Operation() string

func (*Transport) ReplyHeader

func (tr *Transport) ReplyHeader() transport.Header

func (*Transport) Request

func (tr *Transport) Request() *http.Request

func (*Transport) RequestHeader

func (tr *Transport) RequestHeader() transport.Header

type Transporter

type Transporter interface {
	transport.Transporter
	G() *gin.Context
	Request() *http.Request
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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