IronMux
ironmux
is a high performance, zero dependency, middleware focused router used for handling HTTP requests. Its built around the idea of having a request pipeline and adding middleware as you see fit. There are some middleware that comes included, the main one being Endpoints which allows for you to map HTTP verbs to handlers using the standard http.ResponseWriter
and http.Request
.
📦 Installation
go get -u github.com/ironfang-ltd/ironmux
👨💻 Basic Example
package main
import (
"log"
"net/http"
"github.com/ironfang-ltd/ironmux"
"github.com/ironfang-ltd/ironmux/middleware"
)
func main() {
// Create a new instance of the router
r := ironmux.NewRouter()
// Add the endpoint middleware
r.UseMiddleware(middleware.Endpoints(func(e middleware.EndpointsBuilder) {
e.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello!"))
})
}))
log.Fatal(srv.ListenAndServe("127.0.0.1:8000", r.Build()))
}
There are more examples that can be found in the examples directory.
😎 Middleware
There are several included middlewares that can be used or feel free to make your own.
Middleware |
Description |
Endpoints |
Adds basic HTTP routing for GET, POST etc.. |
Logging |
Logs the request to the console |
Files |
Used to serve static files |
RequestID |
Creates an ID for the request and adds it to a response header |
Spa |
Used to serve index.html from a directory, typically used as the last in the pipeline |
Time |
Prints the request execution time to the console |
ProxyHeaders |
Parsed proxy headers such as X-Forwarded-For or X-Real-IP |
✌ Disclaimer
This is my first attempt at learning go as a .NET developer, this is also my first open source project. If you have any advice, contributions or constructive critisism please feel free to help! 😊
📜 License
(c) Copyright 2021, Ironfang Ltd.
Licensed under the MIT License