Documentation
¶
Index ¶
- type APIError
- type App
- func (a *App) Add(path string, setup func(*Group))
- func (a *App) Group(path string) *Group
- func (a *App) Routes() []string
- func (a *App) Run(address string) error
- func (a *App) RunWithConfig(address string, config AppConfig) error
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *App) SetErrorHandler(handler ErrorHandler)
- func (a *App) SetLogger(logger Logger)
- func (a *App) Static(path, dir string)
- func (a *App) Use(middleware ...Middleware)
- func (a *App) UseFunc(handler func(next http.Handler) http.Handler)
- type AppConfig
- type Context
- func (c *Context) Abort()
- func (c *Context) Bind(obj interface{}) error
- func (c *Context) BindAndValidate(obj interface{}) error
- func (c *Context) Cookie(name string) (*http.Cookie, error)
- func (c *Context) Error(status int, message string, args ...interface{})
- func (c *Context) File(filepath string)
- func (c *Context) Get(key string) (interface{}, bool)
- func (c *Context) GetParam(name string) string
- func (c *Context) HTML(status int, html string)
- func (c *Context) HandleError(err error)
- func (c *Context) IsAborted() bool
- func (c *Context) JSON(status int, data interface{})
- func (c *Context) LogRequest()
- func (c *Context) Logger() Logger
- func (c *Context) MustGet(key string) interface{}
- func (c *Context) Query(name string) string
- func (c *Context) QueryDefault(name, defaultValue string) string
- func (c *Context) Redirect(status int, location string)
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetCookie(cookie *http.Cookie)
- func (c *Context) String(status int, format string, values ...interface{})
- func (c *Context) Success(data interface{})
- func (c *Context) WithMeta(data interface{}, meta interface{})
- type ErrorHandler
- type Group
- func (g *Group) DELETE(path string, action HandlerFunc)
- func (g *Group) GET(path string, action HandlerFunc)
- func (g *Group) OPTIONS(path string, action HandlerFunc)
- func (g *Group) PATCH(path string, action HandlerFunc)
- func (g *Group) POST(path string, action HandlerFunc)
- func (g *Group) PUT(path string, action HandlerFunc)
- func (g *Group) Route(path string, action HandlerFunc, methods ...string)
- func (g *Group) Use(middleware ...Middleware)
- type HandlerFunc
- type Logger
- type Middleware
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the main web application structure
func NewWithConfig ¶
NewWithConfig creates a new App with custom configuration
func (*App) RunWithConfig ¶
RunWithConfig starts the HTTP server with the given configuration
func (*App) ServeHTTP ¶ added in v0.0.2
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP allows the App to implement the http.Handler interface
func (*App) SetErrorHandler ¶
func (a *App) SetErrorHandler(handler ErrorHandler)
SetErrorHandler sets a custom error handler
func (*App) Use ¶
func (a *App) Use(middleware ...Middleware)
Use adds middleware to the application
type AppConfig ¶
type AppConfig struct {
CorsOptions cors.Options
ReadTimeout time.Duration
WriteTimeout time.Duration
Logger Logger
ErrorHandler ErrorHandler
}
AppConfig holds configuration for the App
func DefaultAppConfig ¶
func DefaultAppConfig() AppConfig
DefaultAppConfig returns a default configuration
type Context ¶
type Context struct {
Writer http.ResponseWriter
Request *http.Request
Params map[string]string
// contains filtered or unexported fields
}
Context represents the request context
func (*Context) BindAndValidate ¶
BindAndValidate binds and validates request body
func (*Context) HandleError ¶
HandleError handles an error with the registered error handler
func (*Context) LogRequest ¶
func (c *Context) LogRequest()
LogRequest logs information about the current request
func (*Context) QueryDefault ¶
QueryDefault gets a query parameter by name with a default value
type ErrorHandler ¶
ErrorHandler is responsible for handling errors
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represents a group of routes
func (*Group) DELETE ¶
func (g *Group) DELETE(path string, action HandlerFunc)
DELETE registers a route with DELETE method
func (*Group) GET ¶
func (g *Group) GET(path string, action HandlerFunc)
GET registers a route with GET method
func (*Group) OPTIONS ¶
func (g *Group) OPTIONS(path string, action HandlerFunc)
OPTIONS registers a route with OPTIONS method
func (*Group) PATCH ¶
func (g *Group) PATCH(path string, action HandlerFunc)
PATCH registers a route with PATCH method
func (*Group) POST ¶
func (g *Group) POST(path string, action HandlerFunc)
POST registers a route with POST method
func (*Group) PUT ¶
func (g *Group) PUT(path string, action HandlerFunc)
PUT registers a route with PUT method
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc is a function that processes a request with a context
type Logger ¶
type Logger interface {
Info(format string, args ...interface{})
Error(format string, args ...interface{})
Debug(format string, args ...interface{})
}
Logger interface for custom logging
type Middleware ¶
type Middleware func(HandlerFunc) HandlerFunc
Middleware is a function that processes requests before they reach the handler
func TimeoutMiddleware ¶
func TimeoutMiddleware(timeout time.Duration) Middleware
TimeoutMiddleware adds a timeout to the request