Skip to content

RapidRoot is a lightweight and flexible HTTP router library for Go. It simplifies routing, middleware handling, and request/response management in your Go web applications. With an easy-to-use API, RapidRoot empowers developers to quickly define routes, apply middleware, and build robust web services.

License

Notifications You must be signed in to change notification settings

Folium1/RapidRoot

Repository files navigation

RapidRoot

Overview

RapidRoot is a Go package offering efficient HTTP routing capabilities for web applications. It supports various HTTP methods, dynamic routing, middleware, and more.

Features

  • 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.

Installation

go get github.com/Folium1/RapidRoot

Basic Usage

Importing the Package

import rr "github.com/Folium1/RapidRoot"

Creating a Router

router := rr.NewRouter()

Defining Routes

router.GET("/path", handlerFunction)
router.POST("/path", handlerFunction)
// Repeat for other HTTP methods

Starting the Server

For HTTP:

router.Run(":8080")

For HTTPS:

router.RunWithTLS(":443", "certFile", "keyFile")

Handler Function

func handlerFunction(req *rr.Request) {
    // Request handling logic here
}

Middleware

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
    }
}

Applying Middleware

router.Middleware("GET", "/path", yourMiddlewareFunction)

Group Middleware

router.GroupMiddleware("GET", "/api", middlewareFunction1, middlewareFunction2)

Advanced Features

  • Custom request and response manipulation.
  • Secure and flexible cookie handling.
  • Dynamic routing with easy parameter extraction.

Contributing

Contributions are welcome. Please adhere to Go's standard coding style and submit pull requests for any contributions.

License

RapidRoot is released under the MIT License.


Note: For detailed API documentation and advanced usage, refer to the source code comments

About

RapidRoot is a lightweight and flexible HTTP router library for Go. It simplifies routing, middleware handling, and request/response management in your Go web applications. With an easy-to-use API, RapidRoot empowers developers to quickly define routes, apply middleware, and build robust web services.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages