gemrouter

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

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) Get added in v0.0.6

func (store *ContextStore) Get(key string) (any, bool)

func (*ContextStore) Set added in v0.0.6

func (store *ContextStore) Set(key string, val any)

type CorsConfig added in v0.0.5

type CorsConfig struct {
	AllowOrigins     []string
	AllowMethods     []string
	AllowHeaders     []string
	ExposeHeaders    []string
	AllowCredentials bool
	MaxAge           int
}

type GemConfig added in v0.0.3

type GemConfig func(router *GemRouter)

func WithAddr added in v0.0.3

func WithAddr(addr string) GemConfig

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 WithLogger added in v0.0.5

func WithLogger(l GemLogger) 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 WithPort added in v0.0.3

func WithPort(port string) GemConfig

func WithPrometheus added in v0.0.6

func WithPrometheus(metricsPath string) GemConfig

func WithShutdownTimeout added in v0.0.5

func WithShutdownTimeout(d time.Duration) GemConfig

func WithTrustedProxy added in v0.0.5

func WithTrustedProxy() GemConfig

type GemContext

type GemContext struct {
	Writer  http.ResponseWriter
	Request *http.Request
	Store   *ContextStore
	Logger  GemLogger
	Aborted bool
	// 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) Get

func (context *GemContext) Get(key string) (any, bool)

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 GemLogger added in v0.0.5

type GemLogger interface {
	Info(msg string, fields map[string]any)
	Debug(msg string, fields map[string]any)
	Warn(msg string, fields map[string]any)
	Error(msg string, fields map[string]any)
}

type GemRouter

type GemRouter struct {
	Addr string
	Port string

	NotFound 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 NewGemRouter(configs ...GemConfig) *GemRouter

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) Run

func (r *GemRouter) Run() error

func (*GemRouter) Use

func (r *GemRouter) Use(middleware Middleware)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL