Documentation ¶
Index ¶
- Constants
- func CarrierInterceptor(carrier Carrier) gin.HandlerFunc
- func MetadataInterceptor(md Metadata) gin.HandlerFunc
- func TransportInterceptor() gin.HandlerFunc
- func UrlValues(params gin.Params) url.Values
- func WithValueCarrier(ctx context.Context, c Carrier) context.Context
- type Carrier
- type Codec
- func (*Codec) ContentType(_ interface{}) string
- func (c *Codec) Delimiter() []byte
- func (*Codec) Marshal(v interface{}) ([]byte, error)
- func (c *Codec) NewDecoder(r io.Reader) codec.Decoder
- func (c *Codec) NewEncoder(w io.Writer) codec.Encoder
- func (c *Codec) Unmarshal(data []byte, v interface{}) error
- type Context
- type HandlerFunc
- type InitHttpServerFunc
- type Metadata
- type Option
- type Options
- type Server
- func (s *Server) AnyEx(path string, handlers ...HandlerFunc) *Server
- func (s *Server) DeleteEx(path string, handlers ...HandlerFunc) *Server
- func (s *Server) GetEx(path string, handlers ...HandlerFunc) *Server
- func (s *Server) GroupEx(path string, handlers ...HandlerFunc) *Server
- func (s *Server) HandleEx(method, path string, handlers ...HandlerFunc) *Server
- func (s *Server) HeadEx(path string, handlers ...HandlerFunc) *Server
- func (s *Server) Init(opts ...Option)
- func (s *Server) MatchEx(methods []string, path string, handlers ...HandlerFunc) *Server
- func (s *Server) OptionsEx(path string, handlers ...HandlerFunc) *Server
- func (s *Server) PatchEx(path string, handlers ...HandlerFunc) *Server
- func (s *Server) PostEx(path string, handlers ...HandlerFunc) *Server
- func (s *Server) PutEx(path string, handlers ...HandlerFunc) *Server
- func (s *Server) Start() error
- func (s *Server) Stop() error
- func (s *Server) UseEx(middlewares ...HandlerFunc)
- type Transport
- func (tr *Transport) ClientIp() string
- func (tr *Transport) FullPath() string
- func (tr *Transport) GinContext() *gin.Context
- func (tr *Transport) Kind() transport.Kind
- func (tr *Transport) Method() string
- func (tr *Transport) RequestHeader() transport.Header
- func (tr *Transport) ResponseHeader() transport.Header
- func (tr *Transport) Route() string
- type Transporter
Constants ¶
const ExclusivelyMetadataKey = "_wzo/transport/http/metadata"
Variables ¶
This section is empty.
Functions ¶
func CarrierInterceptor ¶
func CarrierInterceptor(carrier Carrier) gin.HandlerFunc
CarrierInterceptor carrier middleware.
func MetadataInterceptor ¶
func MetadataInterceptor(md Metadata) gin.HandlerFunc
MetadataInterceptor is used to store a `ExclusivelyMetadataKey`/Metadata pair exclusively for this `*gin.Context`.
func TransportInterceptor ¶
func TransportInterceptor() gin.HandlerFunc
TransportInterceptor transport middleware
Types ¶
type Carrier ¶
type Carrier interface { // Bind checks the Method and Content-Type to select codec.Marshaler automatically, // Depending on the "Content-Type" header different bind are used. Bind(*gin.Context, any) error // BindQuery binds the passed struct pointer using the query codec.Marshaler. BindQuery(*gin.Context, any) error // BindUri binds the passed struct pointer using the uri codec.Marshaler. // NOTE: before use this, you should set uri params in the request context with RequestWithUri. BindUri(*gin.Context, any) error // Error encode error response. Error(c *gin.Context, err error) // Render encode response. Render(*gin.Context, any) // Validate the request. Validate(context.Context, any) error }
Carrier is an HTTP Carrier. protoc-gen-wzo-gin use disable_template=true options
func FromCarrier ¶
FromCarrier returns the Carrier value stored in ctx, if not exist cause panic.
type Codec ¶
Codec is a Marshaler which marshals/unmarshals into/from JSON/ marshals use encoding/json unmarshals use google.golang.org/protobuf/encoding/protojson
func (*Codec) ContentType ¶
ContentType always Returns "application/json; charset=utf-8".
type Context ¶
func (*Context) ShouldBind ¶
func (*Context) ShouldBindQuery ¶
func (*Context) ShouldBindUri ¶
type HandlerFunc ¶
type HandlerFunc func(*Context)
type InitHttpServerFunc ¶
type Metadata ¶
func GetMetadata ¶
GetMetadata returns the Metadata value stored in `*gin.Context`, if any.
func MustGetMetadata ¶
MustGetMetadata returns the Metadata value stored in `*gin.Context`.
type Option ¶
type Option func(*Options)
func InitHttpServer ¶
func InitHttpServer(f InitHttpServerFunc) Option
type Server ¶
func (*Server) HandleEx ¶
func (s *Server) HandleEx(method, path string, handlers ...HandlerFunc) *Server
func (*Server) MatchEx ¶
func (s *Server) MatchEx(methods []string, path string, handlers ...HandlerFunc) *Server
func (*Server) UseEx ¶
func (s *Server) UseEx(middlewares ...HandlerFunc)
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an HTTP transport.
func (*Transport) GinContext ¶
GinContext Service gin context
func (*Transport) RequestHeader ¶
RequestHeader return transport request header http: http.Header grpc: metadata.MD
func (*Transport) ResponseHeader ¶
ResponseHeader return transport response header http: http.Header grpc: metadata.MD
type Transporter ¶
type Transporter interface { transport.Transporter Method() string Route() string GinContext() *gin.Context }
Transporter is http Transporter