freed/internal/api/api.go
Dennis Schoepf c973859f7f Implements api routes and api key auth
CAUTION: Temporary api key is hardcoded, must be changed
2024-04-26 17:23:55 +02:00

20 lines
426 B
Go

package api
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/keyauth"
)
func Setup(app *fiber.App) {
api := app.Group("/api", keyauth.New(keyauth.Config{
SuccessHandler: successHandler,
ErrorHandler: errHandler,
KeyLookup: "header:x-api-key",
ContextKey: "apiKey",
Validator: validateAPIKey,
}))
v1 := api.Group("/v1")
v1.Get("/users", FetchAllUsersHandler)
}