Documentation
¶
Overview ¶
Package gate provides a lightweight HTTP application container with route registration, middleware support, and nested router handling.
Index ¶
- type App
- func (a *App) AddMiddleware(middleware func(http.Handler) http.Handler)
- func (a *App) Delete(route string, handler func(w http.ResponseWriter, r *http.Request))
- func (a *App) Get(route string, handler func(w http.ResponseWriter, r *http.Request))
- func (a *App) ListenAndServe() error
- func (a *App) NewRouter(prefix string) *Router
- func (a *App) Post(route string, handler func(w http.ResponseWriter, r *http.Request))
- func (a *App) Put(route string, handler func(w http.ResponseWriter, r *http.Request))
- func (a *App) Shutdown(ctx context.Context) error
- type AppOption
- type Router
- func (r *Router) AddMiddleware(middleware func(http.Handler) http.Handler)
- func (r *Router) Delete(route string, handler func(w http.ResponseWriter, r *http.Request))
- func (r *Router) Get(route string, handler func(w http.ResponseWriter, r *http.Request))
- func (r *Router) NewRouter(prefix string) *Router
- func (r *Router) Post(route string, handler func(w http.ResponseWriter, r *http.Request))
- func (r *Router) Put(route string, handler func(w http.ResponseWriter, r *http.Request))
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
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 represents the HTTP application and its route/middleware configuration.
func New ¶
New creates a new App with optional configuration options. The default server address is ":8080" unless overridden.
func (*App) AddMiddleware ¶
AddMiddleware appends a middleware layer to the application. Middleware wraps request handling for all registered routes.
func (*App) ListenAndServe ¶
ListenAndServe applies registered middleware and starts the HTTP server. This method blocks until the server exits.
func (*App) NewRouter ¶
NewRouter creates a nested router mounted under the specified prefix. Requests beginning with the prefix are routed through the new Router.
type AppOption ¶
type AppOption func(*App)
AppOption is a functional configuration option for an App.
func WithLogger ¶
WithLogger sets a custom logger for application startup and request logging. If logger is nil, the default standard logger is preserved.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a nested route container that supports its own middleware and routes.
func (*Router) AddMiddleware ¶
AddMiddleware adds middleware specifically for this router.