Implements api routes and api key auth

CAUTION: Temporary api key is hardcoded, must be changed
This commit is contained in:
Dennis Schoepf 2024-04-26 17:23:55 +02:00
parent 47dab069c3
commit c973859f7f
3 changed files with 83 additions and 0 deletions

20
internal/api/api.go Normal file
View file

@ -0,0 +1,20 @@
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)
}