RapidRoot is a Go package offering efficient HTTP routing capabilities for web applications. It supports various HTTP methods, dynamic routing, middleware, and more.
- HTTP Methods: Supports GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD, CONNECT, TRACE.
- Middleware: Route-specific and group middleware functionality.
- Dynamic Routing: Handles dynamic routes with path parameters.
- Response Utilities: Includes built-in methods for common HTTP responses (JSON, XML, HTML, etc.).
- Request and Response Wrappers: Enhances functionality and flexibility.
- Cookie Management: Secure and customizable handling of cookies.
- Efficient Request Pooling: Reduces garbage collection overhead.
go get github.com/Folium1/RapidRoot
import rr "github.com/Folium1/RapidRoot"
router := rr.NewRouter()
router.GET("/path", handlerFunction)
router.POST("/path", handlerFunction)
// Repeat for other HTTP methods
For HTTP:
router.Run(":8080")
For HTTPS:
router.RunWithTLS(":443", "certFile", "keyFile")
func handlerFunction(req *rr.Request) {
// Request handling logic here
}
func loggingMiddleware(next rapidroot.HandlerFunc) rapidroot.HandlerFunc {
return func(req *rapidroot.Request) {
log.Printf("Request received: %s %s", req.Req.Method, req.Req.URL.Path)
next(req) // Call the next handler
}
}
router.Middleware("GET", "/path", yourMiddlewareFunction)
router.GroupMiddleware("GET", "/api", middlewareFunction1, middlewareFunction2)
- Custom request and response manipulation.
- Secure and flexible cookie handling.
- Dynamic routing with easy parameter extraction.
Contributions are welcome. Please adhere to Go's standard coding style and submit pull requests for any contributions.
RapidRoot is released under the MIT License.
Note: For detailed API documentation and advanced usage, refer to the source code comments