Documentation
¶
Index ¶
- type App
- func (a *App) AddPlugin(p plugins.Plugin)
- func (a *App) Connect(path string, handler req.Handler)
- func (a *App) Delete(path string, handler req.Handler)
- func (a *App) Get(path string, handler req.Handler)
- func (a *App) Head(path string, handler req.Handler)
- func (a *App) Listen(addr string) error
- func (a *App) Options(path string, handler req.Handler)
- func (a *App) Patch(path string, handler req.Handler)
- func (a *App) Post(path string, handler req.Handler)
- func (a *App) Put(path string, handler req.Handler)
- func (a *App) RegisterPlugins()
- func (a *App) Route(method, path string, handler req.Handler)
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *App) Trace(path string, handler req.Handler)
- func (a *App) Use(mw Middleware)
- type Middleware
- type Node
- type Route
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 core web application structure, managing routes, middlewares, and plugins.
func NewApp ¶
func NewApp() *App
NewApp creates a new App instance with an initialized root node. Returns:
*App: A new App instance.
func (*App) AddPlugin ¶
AddPlugin adds a plugin to the App's plugin stack. Args:
p (plugins.Plugin): The plugin to add.
func (*App) Connect ¶
Connect registers a handler for the CONNECT HTTP method. Args:
path (string): The route path. handler (req.Handler): The handler function.
func (*App) Delete ¶
Delete registers a handler for the DELETE HTTP method. Args:
path (string): The route path. handler (req.Handler): The handler function.
func (*App) Get ¶
Get registers a handler for the GET HTTP method. Args:
path (string): The route path. handler (req.Handler): The handler function.
func (*App) Head ¶
Head registers a handler for the HEAD HTTP method. Args:
path (string): The route path. handler (req.Handler): The handler function.
func (*App) Listen ¶
Listen starts the HTTP server on the specified address and handles graceful shutdown. Args:
addr (string): The address to listen on (e.g., ":8080").
Returns:
error: An error if the server fails to start or shutdown.
func (*App) Options ¶
Options registers a handler for the OPTIONS HTTP method. Args:
path (string): The route path. handler (req.Handler): The handler function.
func (*App) Patch ¶
Patch registers a handler for the PATCH HTTP method. Args:
path (string): The route path. handler (req.Handler): The handler function.
func (*App) Post ¶
Post registers a handler for the POST HTTP method. Args:
path (string): The route path. handler (req.Handler): The handler function.
func (*App) Put ¶
Put registers a handler for the PUT HTTP method. Args:
path (string): The route path. handler (req.Handler): The handler function.
func (*App) RegisterPlugins ¶
func (a *App) RegisterPlugins()
RegisterPlugins registers all plugins added to the App.
func (*App) Route ¶
Route registers a route for a specific HTTP method and path. Args:
method (string): The HTTP method (e.g., "GET"). path (string): The route path. handler (req.Handler): The handler function for the route.
func (*App) ServeHTTP ¶
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles incoming HTTP requests and dispatches them to the appropriate route. Args:
w (http.ResponseWriter): The response writer. r (*http.Request): The incoming request.
func (*App) Trace ¶
Trace registers a handler for the TRACE HTTP method. Args:
path (string): The route path. handler (req.Handler): The handler function.
func (*App) Use ¶
func (a *App) Use(mw Middleware)
Use adds a middleware function to the App's middleware stack. Args:
mw (Middleware): The middleware function to add.
type Middleware ¶
type Middleware func(http.HandlerFunc) http.HandlerFunc
Middleware defines a function signature for middleware.