Documentation
¶
Index ¶
- Constants
- func LogDebug(args ...interface{})
- func LogDebugf(format string, args ...interface{})
- func LogError(args ...interface{})
- func LogErrorf(format string, args ...interface{})
- func LogFatal(args ...interface{})
- func LogFatalf(format string, args ...interface{})
- func LogInfo(args ...interface{})
- func LogInfof(format string, args ...interface{})
- func LogWarn(args ...interface{})
- func LogWarnf(format string, args ...interface{})
- func SetOperation(ctx context.Context, op string)
- type Context
- type HandlerFunc
- type Router
- func (r *Router) CONNECT(path string, h HandlerFunc, m ...kHttp.FilterFunc)
- func (r *Router) DELETE(path string, h HandlerFunc, m ...kHttp.FilterFunc)
- func (r *Router) GET(path string, h HandlerFunc, m ...kHttp.FilterFunc)
- func (r *Router) Group(prefix string, filters ...kHttp.FilterFunc) *Router
- func (r *Router) HEAD(path string, h HandlerFunc, m ...kHttp.FilterFunc)
- func (r *Router) Handle(method, relativePath string, h HandlerFunc, filters ...kHttp.FilterFunc)
- func (r *Router) OPTIONS(path string, h HandlerFunc, m ...kHttp.FilterFunc)
- func (r *Router) PATCH(path string, h HandlerFunc, m ...kHttp.FilterFunc)
- func (r *Router) POST(path string, h HandlerFunc, m ...kHttp.FilterFunc)
- func (r *Router) PUT(path string, h HandlerFunc, m ...kHttp.FilterFunc)
- func (r *Router) TRACE(path string, h HandlerFunc, m ...kHttp.FilterFunc)
- type Server
- func (s *Server) Endpoint() (*url.URL, error)
- func (s *Server) Handle(path string, h http.Handler)
- func (s *Server) HandleFunc(path string, h http.HandlerFunc)
- func (s *Server) HandleHeader(key, val string, h http.HandlerFunc)
- func (s *Server) HandlePrefix(prefix string, h http.Handler)
- func (s *Server) Route(prefix string, filters ...kHttp.FilterFunc) *Router
- func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request)
- func (s *Server) Start(_ context.Context) error
- func (s *Server) Stop(_ context.Context) error
- type ServerOption
- func WithAddress(addr string) ServerOption
- func WithErrorEncoder(en kHttp.EncodeErrorFunc) ServerOption
- func WithFilter(filters ...kHttp.FilterFunc) ServerOption
- func WithMiddleware(m ...middleware.Middleware) ServerOption
- func WithRequestDecoder(dec kHttp.DecodeRequestFunc) ServerOption
- func WithResponseEncoder(en kHttp.EncodeResponseFunc) ServerOption
- func WithStrictSlash(strictSlash bool) ServerOption
- func WithTLSConfig(c *tls.Config) ServerOption
- func WithTimeout(timeout time.Duration) ServerOption
- type Transport
- func (tr *Transport) Endpoint() string
- func (tr *Transport) Kind() kratosTransport.Kind
- func (tr *Transport) Operation() string
- func (tr *Transport) PathTemplate() string
- func (tr *Transport) ReplyHeader() kratosTransport.Header
- func (tr *Transport) Request() *http.Request
- func (tr *Transport) RequestHeader() kratosTransport.Header
- type Transporter
Constants ¶
const (
KindHTTP3 = "http3"
)
Variables ¶
This section is empty.
Functions ¶
func SetOperation ¶
SetOperation sets the transport operation.
Types ¶
type Context ¶
type Context interface {
context.Context
Vars() url.Values
Query() url.Values
Form() url.Values
Header() http.Header
Request() *http.Request
Response() http.ResponseWriter
Middleware(middleware.Handler) middleware.Handler
Bind(interface{}) error
BindVars(interface{}) error
BindQuery(interface{}) error
BindForm(interface{}) error
Returns(interface{}, error) error
Result(int, interface{}) error
JSON(int, interface{}) error
XML(int, interface{}) error
String(int, string) error
Blob(int, string, []byte) error
Stream(int, string, io.Reader) error
Reset(http.ResponseWriter, *http.Request)
}
Context is an HTTP Context.
type HandlerFunc ¶
HandlerFunc defines a function to serve HTTP requests.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is an HTTP router.
func (*Router) CONNECT ¶
func (r *Router) CONNECT(path string, h HandlerFunc, m ...kHttp.FilterFunc)
CONNECT registers a new CONNECT route for a path with matching handler in the router.
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, h HandlerFunc, m ...kHttp.FilterFunc)
DELETE registers a new DELETE route for a path with matching handler in the router.
func (*Router) GET ¶
func (r *Router) GET(path string, h HandlerFunc, m ...kHttp.FilterFunc)
GET registers a new GET route for a path with matching handler in the router.
func (*Router) Group ¶
func (r *Router) Group(prefix string, filters ...kHttp.FilterFunc) *Router
Group returns a new router group.
func (*Router) HEAD ¶
func (r *Router) HEAD(path string, h HandlerFunc, m ...kHttp.FilterFunc)
HEAD registers a new HEAD route for a path with matching handler in the router.
func (*Router) Handle ¶
func (r *Router) Handle(method, relativePath string, h HandlerFunc, filters ...kHttp.FilterFunc)
Handle registers a new route with a matcher for the URL path and method.
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(path string, h HandlerFunc, m ...kHttp.FilterFunc)
OPTIONS registers a new OPTIONS route for a path with matching handler in the router.
func (*Router) PATCH ¶
func (r *Router) PATCH(path string, h HandlerFunc, m ...kHttp.FilterFunc)
PATCH registers a new PATCH route for a path with matching handler in the router.
func (*Router) POST ¶
func (r *Router) POST(path string, h HandlerFunc, m ...kHttp.FilterFunc)
POST registers a new POST route for a path with matching handler in the router.
func (*Router) PUT ¶
func (r *Router) PUT(path string, h HandlerFunc, m ...kHttp.FilterFunc)
PUT registers a new PUT route for a path with matching handler in the router.
func (*Router) TRACE ¶
func (r *Router) TRACE(path string, h HandlerFunc, m ...kHttp.FilterFunc)
TRACE registers a new TRACE route for a path with matching handler in the router.
type Server ¶
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
func (*Server) HandleFunc ¶
func (s *Server) HandleFunc(path string, h http.HandlerFunc)
func (*Server) HandleHeader ¶
func (s *Server) HandleHeader(key, val string, h http.HandlerFunc)
type ServerOption ¶
type ServerOption func(*Server)
func WithAddress ¶
func WithAddress(addr string) ServerOption
func WithErrorEncoder ¶
func WithErrorEncoder(en kHttp.EncodeErrorFunc) ServerOption
func WithFilter ¶
func WithFilter(filters ...kHttp.FilterFunc) ServerOption
func WithMiddleware ¶
func WithMiddleware(m ...middleware.Middleware) ServerOption
func WithRequestDecoder ¶
func WithRequestDecoder(dec kHttp.DecodeRequestFunc) ServerOption
func WithResponseEncoder ¶
func WithResponseEncoder(en kHttp.EncodeResponseFunc) ServerOption
func WithStrictSlash ¶
func WithStrictSlash(strictSlash bool) ServerOption
func WithTLSConfig ¶
func WithTLSConfig(c *tls.Config) ServerOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ServerOption
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an HTTP3 transport.
func (*Transport) Kind ¶
func (tr *Transport) Kind() kratosTransport.Kind
Kind returns the transport kind.
func (*Transport) PathTemplate ¶
PathTemplate returns the http path template.
func (*Transport) ReplyHeader ¶
func (tr *Transport) ReplyHeader() kratosTransport.Header
ReplyHeader returns the reply header.
func (*Transport) RequestHeader ¶
func (tr *Transport) RequestHeader() kratosTransport.Header
RequestHeader returns the request header.
type Transporter ¶
type Transporter interface {
kratosTransport.Transporter
Request() *http.Request
PathTemplate() string
}
Transporter is http Transporter