Documentation ¶
Overview ¶
Package gins is a gin extension package.
Package gins is a gin extension package.
Package gins is a gin extension package.
Package gins is a gin extension package.
Package gins is a gin extension package.
Package gins is a gin extension package.
Package gins is a gin extension package.
Package gins is a gin extension package.
Package gins is a gin extension package.
Package gins implements the functions, types, and interfaces for the module.
Package gins is a gin extension package.
Package gins is a gin extension package.
Package gins is a gin extension package.
Index ¶
- Constants
- func Bind(ctx *Context, obj any) error
- func BindBody(ctx *Context, obj any) error
- func BindQuery(ctx *Context, target interface{}) error
- func BindURI(ctx *Context, target interface{}) error
- func CodecForRequest(c *Context, name string) (encoding.Codec, bool)
- func CodecName(name string) string
- func ContentType(subtype string) string
- func DefaultErrorEncoder(c *Context, err error)
- func DefaultRequestDecoder(c *Context, v interface{}) error
- func DefaultRequestQuery(c *Context, v interface{}) error
- func DefaultRequestVars(c *Context, v interface{}) error
- func DefaultResponseEncoder(c *Context, v interface{}) error
- func EncodeURL(pathTemplate string, msg interface{}, needQuery bool) string
- func FromContext(ctx context.Context) (*gin.Context, bool)
- func NewContext(ctx *gin.Context) context.Context
- func NewEndpoint(scheme, host string) *url.URL
- func ParseEndpoint(endpoints []string, scheme string) (string, error)
- func ResultError(c *Context, err error, status ...int)
- func ResultJSON(c *gin.Context, status int, resp pagination.Responder)
- func ResultOK(c *gin.Context)
- func ResultPage(c *gin.Context, resp pagination.Responder, args ...map[string]any)
- func ResultSuccess(c *gin.Context, resp pagination.Responder)
- func Scheme(scheme string, isSecure bool) string
- func SetOperation(ctx context.Context, op string)
- type CallOption
- type Client
- type Context
- type DecodeRequestFunc
- type EncodeErrorFunc
- type EncodeResponseFunc
- type Engine
- type Flusher
- type HandlerFunc
- type IRouter
- type IRoutes
- type Redirector
- type Request
- type ResponseController
- type ResponseWriter
- type Result
- type RouteInfo
- type RouterGroup
- type RoutesInfo
- type Server
- func (s *Server) Any(path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) DELETE(path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) Endpoint() (*url.URL, error)
- func (s *Server) GET(path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) Group(path string, handlers ...HandlerFunc) *RouterGroup
- func (s *Server) HEAD(path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) Handle(method, path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) Match(methods []string, path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) OPTIONS(path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) PATCH(path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) POST(path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) PUT(path string, handlers ...HandlerFunc) IRoutes
- func (s *Server) Route(prefix string, filters ...HandlerFunc) IRoutes
- func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request)
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) Static(path string, root string) IRoutes
- func (s *Server) StaticFS(path string, system http.FileSystem) IRoutes
- func (s *Server) StaticFile(path string, filepath string) IRoutes
- func (s *Server) StaticFileFS(path string, filepath string, system http.FileSystem) IRoutes
- func (s *Server) Stop(ctx context.Context) error
- func (s *Server) Use(handlers ...HandlerFunc) IRoutes
- func (s *Server) WalkHandle(handle func(method, path string, handler http.HandlerFunc)) error
- func (s *Server) WalkRoute(fn WalkRouteFunc) error
- type ServerOption
- func Address(addr string) ServerOption
- func Endpoint(endpoint *url.URL) ServerOption
- func Filter(filters ...HandlerFunc) ServerOption
- func Listener(lis net.Listener) ServerOption
- func MethodNotAllowedHandler(handlers ...HandlerFunc) ServerOption
- func Middleware(m ...middleware.Middleware) ServerOption
- func Network(network string) ServerOption
- func NotFoundHandler(handlers ...HandlerFunc) ServerOption
- func StrictSlash(strictSlash bool) ServerOption
- func TLSConfig(c *tls.Config) ServerOption
- func Timeout(timeout time.Duration) ServerOption
- func WithLogger(l log.Logger) ServerOption
- func WithTLSConfig(c *tls.Config) ServerOption
- type Transport
- func (tr *Transport) Endpoint() string
- func (tr *Transport) Kind() transport.Kind
- func (tr *Transport) Operation() string
- func (tr *Transport) PathTemplate() string
- func (tr *Transport) ReplyHeader() transport.Header
- func (tr *Transport) Request() *http.Request
- func (tr *Transport) RequestHeader() transport.Header
- type Transporter
- type WalkRouteFunc
Constants ¶
const ( ContextRequestBodyBytesKey = "_gins_context_request_body_bytes" ContextResponseBodBytesKey = "_gins_context_response_body_bytes" )
const (
ErrorTypePrivate = gin.ErrorTypePrivate
)
const (
KindGin transport.Kind = "gin"
)
const SupportPackageIsVersion1 = transhttp.SupportPackageIsVersion1
SupportPackageIsVersion1 These constants should not be referenced from any other code.
Variables ¶
This section is empty.
Functions ¶
func CodecForRequest ¶
CodecForRequest get encoding.Codec via http.Request
func ContentType ¶
ContentType returns the content-type with base prefix.
func DefaultErrorEncoder ¶
DefaultErrorEncoder encodes the error to the HTTP response.
func DefaultRequestDecoder ¶
DefaultRequestDecoder decodes the request body to object.
func DefaultRequestQuery ¶
DefaultRequestQuery decodes the request vars to object.
func DefaultRequestVars ¶
DefaultRequestVars decodes the request vars to object.
func DefaultResponseEncoder ¶
DefaultResponseEncoder encodes the object to the HTTP response.
func FromContext ¶
FromContext takes a context as an argument and returns a pointer to a gin.Context and a boolean value.
func NewContext ¶
NewContext creates a new context from a gin context
func ParseEndpoint ¶
ParseEndpoint parses an Endpoint URL.
func ResultError ¶ added in v0.0.13
ResultError result error data with status code
func ResultJSON ¶ added in v0.0.13
func ResultJSON(c *gin.Context, status int, resp pagination.Responder)
ResultJSON result json data with status code
func ResultPage ¶ added in v0.0.13
ResultPage result page data with status code
func ResultSuccess ¶ added in v0.0.13
func ResultSuccess(c *gin.Context, resp pagination.Responder)
ResultSuccess result success data with status code
func Scheme ¶
Scheme is the scheme of endpoint url. examples: scheme="http",isSecure=true get "https"
func SetOperation ¶
SetOperation sets the transport operation.
Types ¶
type CallOption ¶
type CallOption = transhttp.CallOption
CallOption configures a Call before it starts or extracts information from a Call after it completes.
type DecodeRequestFunc ¶
DecodeRequestFunc is decode request func.
type EncodeErrorFunc ¶
EncodeErrorFunc is encode error func.
type EncodeResponseFunc ¶
EncodeResponseFunc is encode response func.
type HandlerFunc ¶
type HandlerFunc = gin.HandlerFunc
func Logger ¶
func Logger(logger log.Logger) HandlerFunc
Logger receives the gin framework default log
func Middlewares ¶
func Middlewares(m ...middleware.Middleware) HandlerFunc
Middlewares return middlewares wrapper
type Redirector ¶
Redirector replies to the request with a redirect to url which may be a path relative to the request path.
type ResponseController ¶
type ResponseController = http.ResponseController
ResponseController is type net/http.ResponseController which was added in Go 1.20.
type Result ¶ added in v0.0.10
type Result struct { pagination.UnimplementedResponder `json:"-"` Success bool `json:"success"` Total int64 `json:"total,omitempty"` Data any `json:"data,omitempty"` Extra any `json:"extra,omitempty"` Error *httperr.Error `json:"error,omitempty"` }
func (Result) GetSuccess ¶ added in v0.0.13
type RouterGroup ¶
type RouterGroup = gin.RouterGroup
type RoutesInfo ¶
type RoutesInfo = gin.RoutesInfo
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
func (*Server) Group ¶
func (s *Server) Group(path string, handlers ...HandlerFunc) *RouterGroup
func (*Server) Handle ¶
func (s *Server) Handle(method, path string, handlers ...HandlerFunc) IRoutes
func (*Server) Match ¶
func (s *Server) Match(methods []string, path string, handlers ...HandlerFunc) IRoutes
func (*Server) StaticFileFS ¶
func (*Server) Use ¶
func (s *Server) Use(handlers ...HandlerFunc) IRoutes
func (*Server) WalkHandle ¶
func (s *Server) WalkHandle(handle func(method, path string, handler http.HandlerFunc)) error
WalkHandle walks the router and all its sub-routers, calling walkFn for each route in the tree.
func (*Server) WalkRoute ¶
func (s *Server) WalkRoute(fn WalkRouteFunc) error
WalkRoute walks the router and all its sub-routers, calling walkFn for each route in the tree.
type ServerOption ¶
type ServerOption func(*Server)
func Address ¶
func Address(addr string) ServerOption
func MethodNotAllowedHandler ¶
func MethodNotAllowedHandler(handlers ...HandlerFunc) ServerOption
func Middleware ¶
func Middleware(m ...middleware.Middleware) ServerOption
Middleware with service middleware option.
func NotFoundHandler ¶
func NotFoundHandler(handlers ...HandlerFunc) ServerOption
func StrictSlash ¶
func StrictSlash(strictSlash bool) ServerOption
func WithTLSConfig ¶
func WithTLSConfig(c *tls.Config) ServerOption
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an HTTP transport.
func (*Transport) PathTemplate ¶
PathTemplate returns the http path template.
func (*Transport) ReplyHeader ¶
ReplyHeader returns the reply header.
func (*Transport) RequestHeader ¶
RequestHeader returns the request header.
type WalkRouteFunc ¶
WalkRouteFunc is the type of the function called for each route visited by Walk.