Documentation
¶
Index ¶
- type ContextStore
- type CorsConfig
- type GemConfig
- func WithAddr(addr string) GemConfig
- func WithCors(cfg *CorsConfig) GemConfig
- func WithCorsDefault() GemConfig
- func WithHealth(handler GemHandler) GemConfig
- func WithIdleTimeout(d time.Duration) GemConfig
- func WithJSONLogger(w io.Writer, level slog.Level) GemConfig
- func WithLogger(l *slog.Logger) GemConfig
- func WithMethodNotAllowed(handler GemHandler) GemConfig
- func WithMiddleware(middleware Middleware) GemConfig
- func WithMiddlewares(middlewares []Middleware) GemConfig
- func WithNotFound(handler GemHandler) GemConfig
- func WithPort(port string) GemConfig
- func WithPrometheus(metricsPath string) GemConfig
- func WithReadTimeout(d time.Duration) GemConfig
- func WithShutdownTimeout(d time.Duration) GemConfig
- func WithTextLogger(w io.Writer, level slog.Level) GemConfig
- func WithTrustedProxy() GemConfig
- func WithWriteTimeout(d time.Duration) GemConfig
- type GemContext
- func (context *GemContext) Cookie(name string) (string, error)
- func (context *GemContext) Copy() *GemContext
- func (context *GemContext) DeleteCookie(name string)
- func (context *GemContext) FromJSON(data any) error
- func (context *GemContext) Get(key string) (any, bool)
- func (context *GemContext) Header(key string) string
- func (context *GemContext) Method() string
- func (context *GemContext) NOTFOUND()
- func (context *GemContext) NoContent(code int)
- func (context *GemContext) OK()
- func (context *GemContext) Param(key string) string
- func (context *GemContext) Path() string
- func (context *GemContext) Query(key string) string
- func (context *GemContext) RequestID() string
- func (context *GemContext) Set(key string, val any)
- func (context *GemContext) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
- func (context *GemContext) Status(code int)
- func (context *GemContext) StatusCode() int
- func (context *GemContext) String(code int, text string)
- func (context *GemContext) ToJSON(code int, data any)
- type GemGroup
- func (g *GemGroup) DELETE(pattern string, handler GemHandler)
- func (g *GemGroup) GET(pattern string, handler GemHandler)
- func (g *GemGroup) Group(prefix string, middlewares ...Middleware) *GemGroup
- func (g *GemGroup) PATCH(pattern string, handler GemHandler)
- func (g *GemGroup) POST(pattern string, handler GemHandler)
- func (g *GemGroup) PUT(pattern string, handler GemHandler)
- func (g *GemGroup) Use(m Middleware)
- type GemHandler
- type GemRouter
- func (r *GemRouter) DELETE(pattern string, handler GemHandler)
- func (r *GemRouter) GET(pattern string, handler GemHandler)
- func (r *GemRouter) Group(prefix string, middlewares ...Middleware) *GemGroup
- func (r *GemRouter) NoRoute(handler GemHandler)
- func (r *GemRouter) PATCH(pattern string, handler GemHandler)
- func (r *GemRouter) POST(pattern string, handler GemHandler)
- func (r *GemRouter) PUT(pattern string, handler GemHandler)
- func (r *GemRouter) Run() error
- func (r *GemRouter) Use(middleware Middleware)
- type GemValidator
- type JSON
- type Middleware
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextStore ¶ added in v0.0.6
type ContextStore struct {
RequestID string
UserID string
// contains filtered or unexported fields
}
func (*ContextStore) Set ¶ added in v0.0.6
func (store *ContextStore) Set(key string, val any)
type CorsConfig ¶ added in v0.0.5
type GemConfig ¶ added in v0.0.3
type GemConfig func(router *GemRouter)
func WithCors ¶ added in v0.0.5
func WithCors(cfg *CorsConfig) GemConfig
func WithCorsDefault ¶ added in v0.0.5
func WithCorsDefault() GemConfig
func WithHealth ¶ added in v0.0.3
func WithHealth(handler GemHandler) GemConfig
func WithIdleTimeout ¶ added in v0.0.7
func WithLogger ¶ added in v0.0.5
func WithMethodNotAllowed ¶ added in v0.0.8
func WithMethodNotAllowed(handler GemHandler) GemConfig
func WithMiddleware ¶ added in v0.0.3
func WithMiddleware(middleware Middleware) GemConfig
func WithMiddlewares ¶ added in v0.0.3
func WithMiddlewares(middlewares []Middleware) GemConfig
func WithNotFound ¶ added in v0.0.3
func WithNotFound(handler GemHandler) GemConfig
func WithPrometheus ¶ added in v0.0.6
func WithReadTimeout ¶ added in v0.0.7
func WithShutdownTimeout ¶ added in v0.0.5
func WithTrustedProxy ¶ added in v0.0.5
func WithTrustedProxy() GemConfig
func WithWriteTimeout ¶ added in v0.0.7
type GemContext ¶
type GemContext struct {
Writer http.ResponseWriter
Request *http.Request
Store *ContextStore
Logger *slog.Logger
Pattern string
// contains filtered or unexported fields
}
func (*GemContext) Cookie ¶ added in v0.0.5
func (context *GemContext) Cookie(name string) (string, error)
func (*GemContext) Copy ¶ added in v0.0.5
func (context *GemContext) Copy() *GemContext
func (*GemContext) DeleteCookie ¶ added in v0.0.5
func (context *GemContext) DeleteCookie(name string)
func (*GemContext) FromJSON ¶ added in v0.0.5
func (context *GemContext) FromJSON(data any) error
func (*GemContext) Header ¶
func (context *GemContext) Header(key string) string
func (*GemContext) Method ¶
func (context *GemContext) Method() string
func (*GemContext) NOTFOUND ¶ added in v0.0.3
func (context *GemContext) NOTFOUND()
func (*GemContext) NoContent ¶
func (context *GemContext) NoContent(code int)
func (*GemContext) OK ¶
func (context *GemContext) OK()
func (*GemContext) Param ¶
func (context *GemContext) Param(key string) string
func (*GemContext) Path ¶
func (context *GemContext) Path() string
func (*GemContext) Query ¶
func (context *GemContext) Query(key string) string
func (*GemContext) RequestID ¶ added in v0.0.5
func (context *GemContext) RequestID() string
func (*GemContext) Set ¶
func (context *GemContext) Set(key string, val any)
func (*GemContext) SetCookie ¶ added in v0.0.5
func (context *GemContext) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
func (*GemContext) Status ¶
func (context *GemContext) Status(code int)
func (*GemContext) StatusCode ¶
func (context *GemContext) StatusCode() int
func (*GemContext) String ¶
func (context *GemContext) String(code int, text string)
func (*GemContext) ToJSON ¶
func (context *GemContext) ToJSON(code int, data any)
type GemGroup ¶
type GemGroup struct {
// contains filtered or unexported fields
}
func (*GemGroup) DELETE ¶
func (g *GemGroup) DELETE(pattern string, handler GemHandler)
func (*GemGroup) GET ¶
func (g *GemGroup) GET(pattern string, handler GemHandler)
func (*GemGroup) Group ¶ added in v0.0.5
func (g *GemGroup) Group(prefix string, middlewares ...Middleware) *GemGroup
func (*GemGroup) PATCH ¶
func (g *GemGroup) PATCH(pattern string, handler GemHandler)
func (*GemGroup) POST ¶
func (g *GemGroup) POST(pattern string, handler GemHandler)
func (*GemGroup) PUT ¶
func (g *GemGroup) PUT(pattern string, handler GemHandler)
func (*GemGroup) Use ¶ added in v0.0.5
func (g *GemGroup) Use(m Middleware)
type GemHandler ¶
type GemHandler func(ctx *GemContext)
func Logger ¶
func Logger(next GemHandler) GemHandler
func Recovery ¶
func Recovery(next GemHandler) GemHandler
type GemRouter ¶
type GemRouter struct {
Addr string
Port string
NotFound GemHandler
MethodNotAllowed GemHandler
Health GemHandler
// contains filtered or unexported fields
}
func BasicGemRouter ¶ added in v0.0.6
func BasicGemRouter() *GemRouter
func DefaultGemRouter ¶ added in v0.0.5
func DefaultGemRouter() *GemRouter
func NewGemRouter ¶
func (*GemRouter) DELETE ¶
func (r *GemRouter) DELETE(pattern string, handler GemHandler)
func (*GemRouter) GET ¶
func (r *GemRouter) GET(pattern string, handler GemHandler)
func (*GemRouter) Group ¶
func (r *GemRouter) Group(prefix string, middlewares ...Middleware) *GemGroup
func (*GemRouter) NoRoute ¶
func (r *GemRouter) NoRoute(handler GemHandler)
func (*GemRouter) PATCH ¶
func (r *GemRouter) PATCH(pattern string, handler GemHandler)
func (*GemRouter) POST ¶
func (r *GemRouter) POST(pattern string, handler GemHandler)
func (*GemRouter) PUT ¶
func (r *GemRouter) PUT(pattern string, handler GemHandler)
func (*GemRouter) Use ¶
func (r *GemRouter) Use(middleware Middleware)
type GemValidator ¶ added in v0.0.8
type GemValidator struct {
// contains filtered or unexported fields
}
func NewValidator ¶ added in v0.0.8
func NewValidator() *GemValidator
func (*GemValidator) Check ¶ added in v0.0.8
func (v *GemValidator) Check(field string, value any, rules string) *GemValidator
func (*GemValidator) Errors ¶ added in v0.0.8
func (v *GemValidator) Errors() []ValidationError
func (*GemValidator) Valid ¶ added in v0.0.8
func (v *GemValidator) Valid() bool
type Middleware ¶
type Middleware func(GemHandler) GemHandler
func Cors ¶ added in v0.0.5
func Cors(cfg *CorsConfig) Middleware
func Timeout ¶ added in v0.0.5
func Timeout(d time.Duration) Middleware
type ValidationError ¶ added in v0.0.8
Click to show internal directories.
Click to hide internal directories.