Documentation
¶
Index ¶
- Constants
- func ContentSubtype(contentType string) string
- type BindFunc
- type Ctx
- func (c *Ctx) Bind(v any) error
- func (c *Ctx) BindBody(v any) error
- func (c *Ctx) BindForm(v any) error
- func (c *Ctx) BindHeader(v any) error
- func (c *Ctx) BindJSON(v any) error
- func (c *Ctx) BindMultipart(v any) error
- func (c *Ctx) BindPath(v any) error
- func (c *Ctx) BindQuery(v any) error
- func (c *Ctx) Data(code int, contentType string, data []byte) error
- func (c *Ctx) Get(key any) any
- func (c *Ctx) Header(key string) string
- func (c *Ctx) JSON(code int, v any) error
- func (c *Ctx) Param(key string) string
- func (c *Ctx) Query(key string) string
- func (c *Ctx) RawWriter() http.ResponseWriter
- func (c *Ctx) Render(code int, v any) error
- func (c *Ctx) Request() *http.Request
- func (c *Ctx) Set(key, value any)
- func (c *Ctx) String(code int, format string, args ...any) error
- func (c *Ctx) Validate(v any) error
- func (c *Ctx) Writer() *ResponseWriter
- type HandlerFunc
- type Middleware
- type RenderFunc
- type ResponseWriter
- func (w *ResponseWriter) Flush()
- func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (w *ResponseWriter) Push(target string, opts *http.PushOptions) error
- func (w *ResponseWriter) Size() int
- func (w *ResponseWriter) Status() int
- func (w *ResponseWriter) Unwrap() http.ResponseWriter
- func (w *ResponseWriter) Write(data []byte) (int, error)
- func (w *ResponseWriter) WriteHeader(code int)
- func (w *ResponseWriter) Written() bool
- type RouteBuilder
- func DELETE[Req any, Resp any](router *Router, path string, ...) *RouteBuilder[Req, Resp]
- func GET[Req any, Resp any](router *Router, path string, ...) *RouteBuilder[Req, Resp]
- func HEAD[Req any, Resp any](router *Router, path string, ...) *RouteBuilder[Req, Resp]
- func OPTIONS[Req any, Resp any](router *Router, path string, ...) *RouteBuilder[Req, Resp]
- func PATCH[Req any, Resp any](router *Router, path string, ...) *RouteBuilder[Req, Resp]
- func POST[Req any, Resp any](router *Router, path string, ...) *RouteBuilder[Req, Resp]
- func PUT[Req any, Resp any](router *Router, path string, ...) *RouteBuilder[Req, Resp]
- func (b *RouteBuilder[Req, Resp]) Description(description string) *RouteBuilder[Req, Resp]
- func (b *RouteBuilder[Req, Resp]) Middlewares(mws ...Middleware) *RouteBuilder[Req, Resp]
- func (b *RouteBuilder[Req, Resp]) Register()
- func (b *RouteBuilder[Req, Resp]) Summary(summary string) *RouteBuilder[Req, Resp]
- func (b *RouteBuilder[Req, Resp]) Tags(tags ...string) *RouteBuilder[Req, Resp]
- type Router
- func (r *Router) CONNECT(relativePath string, handler HandlerFunc, middleware ...Middleware)
- func (r *Router) DELETE(relativePath string, handler HandlerFunc, middleware ...Middleware)
- func (r *Router) GET(relativePath string, handler HandlerFunc, middleware ...Middleware)
- func (r *Router) Group(prefix string, middleware ...Middleware) *Router
- func (r *Router) HEAD(relativePath string, handler HandlerFunc, middleware ...Middleware)
- func (r *Router) Mount(prefix string, handler http.Handler, middleware ...Middleware)
- func (r *Router) OPTIONS(relativePath string, handler HandlerFunc, middleware ...Middleware)
- func (r *Router) PATCH(relativePath string, handler HandlerFunc, middleware ...Middleware)
- func (r *Router) POST(relativePath string, handler HandlerFunc, middleware ...Middleware)
- func (r *Router) PUT(relativePath string, handler HandlerFunc, middleware ...Middleware)
- func (r *Router) TRACE(relativePath string, handler HandlerFunc, middleware ...Middleware)
- func (r *Router) Use(middleware ...Middleware)
- type Server
- type ServerOption
- func WithAddr(addr string) ServerOption
- func WithIdleTimeout(timeout time.Duration) ServerOption
- func WithMiddleware(md ...Middleware) ServerOption
- func WithOpenAPISpec(spec openapi.Config) ServerOption
- func WithReadHeaderTimeout(timeout time.Duration) ServerOption
- func WithReadTimeout(timeout time.Duration) ServerOption
- func WithWriteTimeout(timeout time.Duration) ServerOption
- type Validator
Constants ¶
const DefaultMaxMemory = 32 << 20 // 32MB
DefaultMaxMemory is the default max memory for multipart form.
Variables ¶
This section is empty.
Functions ¶
func ContentSubtype ¶
Types ¶
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
Ctx encapsulates the HTTP request and response, providing convenient methods for binding, validation, and rendering. It is passed to all handlers and middleware in the framework.
func (*Ctx) Bind ¶
Bind binds request parameters to the struct. It supports query, path, and body binding. If the request method is GET, HEAD, OPTIONS, or DELETE, it binds query and path parameters. If the request method is POST, PUT or PATCH, it binds body and path parameters.
func (*Ctx) BindMultipart ¶
func (*Ctx) RawWriter ¶
func (c *Ctx) RawWriter() http.ResponseWriter
RawWriter returns the underlying http.ResponseWriter.
type HandlerFunc ¶
HandlerFunc is the handler function signature
type RenderFunc ¶
type ResponseWriter ¶
type ResponseWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter) *ResponseWriter
func (*ResponseWriter) Flush ¶
func (w *ResponseWriter) Flush()
func (*ResponseWriter) Hijack ¶
func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (*ResponseWriter) Push ¶
func (w *ResponseWriter) Push(target string, opts *http.PushOptions) error
func (*ResponseWriter) Size ¶
func (w *ResponseWriter) Size() int
func (*ResponseWriter) Status ¶
func (w *ResponseWriter) Status() int
func (*ResponseWriter) Unwrap ¶
func (w *ResponseWriter) Unwrap() http.ResponseWriter
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(code int)
func (*ResponseWriter) Written ¶
func (w *ResponseWriter) Written() bool
type RouteBuilder ¶
RouteBuilder is a generic route builder supporting method chaining
func DELETE ¶
func DELETE[Req any, Resp any]( router *Router, path string, handler func(ctx context.Context, req *Req) (*Resp, error), ) *RouteBuilder[Req, Resp]
DELETE creates a DELETE route builder (not auto-registered, call Register needed)
func GET ¶
func GET[Req any, Resp any]( router *Router, path string, handler func(ctx context.Context, req *Req) (*Resp, error), ) *RouteBuilder[Req, Resp]
GET creates a GET route builder (not auto-registered, call Register needed)
func HEAD ¶
func HEAD[Req any, Resp any]( router *Router, path string, handler func(ctx context.Context, req *Req) (*Resp, error), ) *RouteBuilder[Req, Resp]
HEAD creates a HEAD route builder (not auto-registered, call Register needed)
func OPTIONS ¶
func OPTIONS[Req any, Resp any]( router *Router, path string, handler func(ctx context.Context, req *Req) (*Resp, error), ) *RouteBuilder[Req, Resp]
OPTIONS creates an OPTIONS route builder (not auto-registered, call Register needed)
func PATCH ¶
func PATCH[Req any, Resp any]( router *Router, path string, handler func(ctx context.Context, req *Req) (*Resp, error), ) *RouteBuilder[Req, Resp]
PATCH creates a PATCH route builder (not auto-registered, call Register needed)
func POST ¶
func POST[Req any, Resp any]( router *Router, path string, handler func(ctx context.Context, req *Req) (*Resp, error), ) *RouteBuilder[Req, Resp]
POST creates a POST route builder (not auto-registered, call Register needed)
func PUT ¶
func PUT[Req any, Resp any]( router *Router, path string, handler func(ctx context.Context, req *Req) (*Resp, error), ) *RouteBuilder[Req, Resp]
PUT creates a PUT route builder (not auto-registered, call Register needed)
func (*RouteBuilder[Req, Resp]) Description ¶
func (b *RouteBuilder[Req, Resp]) Description(description string) *RouteBuilder[Req, Resp]
Description sets the route description, returns self for chaining
func (*RouteBuilder[Req, Resp]) Middlewares ¶
func (b *RouteBuilder[Req, Resp]) Middlewares(mws ...Middleware) *RouteBuilder[Req, Resp]
Middlewares sets the route middlewares, returns self for chaining
func (*RouteBuilder[Req, Resp]) Register ¶
func (b *RouteBuilder[Req, Resp]) Register()
Register registers the route to the router (end of chain)
func (*RouteBuilder[Req, Resp]) Summary ¶
func (b *RouteBuilder[Req, Resp]) Summary(summary string) *RouteBuilder[Req, Resp]
Summary sets the route summary, returns self for chaining
func (*RouteBuilder[Req, Resp]) Tags ¶
func (b *RouteBuilder[Req, Resp]) Tags(tags ...string) *RouteBuilder[Req, Resp]
Tags sets the route tags, returns self for chaining
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) CONNECT ¶
func (r *Router) CONNECT(relativePath string, handler HandlerFunc, middleware ...Middleware)
func (*Router) DELETE ¶
func (r *Router) DELETE(relativePath string, handler HandlerFunc, middleware ...Middleware)
func (*Router) GET ¶
func (r *Router) GET(relativePath string, handler HandlerFunc, middleware ...Middleware)
func (*Router) HEAD ¶
func (r *Router) HEAD(relativePath string, handler HandlerFunc, middleware ...Middleware)
func (*Router) Mount ¶
func (r *Router) Mount(prefix string, handler http.Handler, middleware ...Middleware)
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(relativePath string, handler HandlerFunc, middleware ...Middleware)
func (*Router) PATCH ¶
func (r *Router) PATCH(relativePath string, handler HandlerFunc, middleware ...Middleware)
func (*Router) POST ¶
func (r *Router) POST(relativePath string, handler HandlerFunc, middleware ...Middleware)
func (*Router) PUT ¶
func (r *Router) PUT(relativePath string, handler HandlerFunc, middleware ...Middleware)
func (*Router) TRACE ¶
func (r *Router) TRACE(relativePath string, handler HandlerFunc, middleware ...Middleware)
func (*Router) Use ¶
func (r *Router) Use(middleware ...Middleware)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
type ServerOption ¶
type ServerOption func(*Server)
func WithAddr ¶
func WithAddr(addr string) ServerOption
func WithIdleTimeout ¶
func WithIdleTimeout(timeout time.Duration) ServerOption
func WithMiddleware ¶
func WithMiddleware(md ...Middleware) ServerOption
func WithOpenAPISpec ¶
func WithOpenAPISpec(spec openapi.Config) ServerOption
func WithReadHeaderTimeout ¶
func WithReadHeaderTimeout(timeout time.Duration) ServerOption
func WithReadTimeout ¶
func WithReadTimeout(timeout time.Duration) ServerOption
func WithWriteTimeout ¶
func WithWriteTimeout(timeout time.Duration) ServerOption
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
protoc-gen-go-httpx
command
|
|
|
proto
Package proto defines the protobuf codec.
|
Package proto defines the protobuf codec. |
|
Package errors provides standardized error types for httpx
|
Package errors provides standardized error types for httpx |