Atreugo
Micro-framework to make simple the use of routing and middlewares in fasthttp.
The project use dep manager dependencies.
Note:
*atreugo.RequestCtx
is equal than *fasthttp.RequestCtx
, but adding extra funtionality, so you can use
the same functions of *fasthttp.RequestCtx
. Don't worry :smile:
Example:
package main
import (
"errors"
"github.com/valyala/fasthttp"
"github.com/savsgio/atreugo"
)
func main() {
config := &atreugo.Config{
Host: "0.0.0.0",
Port: 8000,
}
server := atreugo.New(config)
fnMiddlewareOne := func(ctx *atreugo.RequestCtx) (int, error) {
return fasthttp.StatusOK, nil
}
fnMiddlewareTwo := func(ctx *atreugo.RequestCtx) (int, error) {
return fasthttp.StatusBadRequest, errors.New("Error example")
}
server.UseMiddleware(fnMiddlewareOne, fnMiddlewareTwo)
server.Path("GET", "/", func(ctx *atreugo.RequestCtx) error {
return ctx.HTTPResponse("<h1>Atreugo Micro-Framework</h1>")
})
server.Path("GET", "/jsonPage", func(ctx *atreugo.RequestCtx) error {
return ctx.JSONResponse(atreugo.JSON{"Atreugo": true})
})
err := server.ListenAndServe()
if err != nil {
panic(err)
}
}
Useful third-party libraries
Contributing
Feel free to contribute it or fork me... :wink: