Implements api routes and api key auth
CAUTION: Temporary api key is hardcoded, must be changed
This commit is contained in:
parent
47dab069c3
commit
c973859f7f
3 changed files with 83 additions and 0 deletions
20
internal/api/api.go
Normal file
20
internal/api/api.go
Normal 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue