package
0.0.0-20240104213556-8d3c2691da6e
Repository: https://github.com/piterweb/alf-router.git
Documentation: pkg.go.dev
# README
Util 🧩 JSON
Send JSON Responses
Usage :
Import it to your code ðŸ”
import (
alfJSON "github.com/PiterWeb/Alf-Router/utils/json"
)
Create your custom Struct or a Map
type MyCustomResponse struct {
Message string
}
Start sending JSON across your API Endpoints
err := alf.App(&alf.AppConfig{
Port: "3000",
Routes: alf.CreateRouter([]alf.Route{
{
Path: "/api",
Handle: func(ctx *alf.Ctx) error {
_, err := alfJSON.JSON(ctx, MyCustomResponse{
Message: "Hello World",
})
return err
},
Method: "get",
},
}),
})
if err != nil {
panic(err)
}