MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / getAPIKeyFromRequest

Function getAPIKeyFromRequest

api/pkg/middlewares/api_key_auth_middleware.go:40–61  ·  view source on GitHub ↗
(c fiber.Ctx)

Source from the content-addressed store, hash-verified

38}
39
40func getAPIKeyFromRequest(c fiber.Ctx) string {
41 apiKey := c.Get(authHeaderAPIKey)
42 if len(apiKey) != 0 {
43 return apiKey
44 }
45
46 payload := struct {
47 APIKey string `json:"x-api-key" form:"x-api-key" query:"x-api-key"`
48 }{}
49
50 if c.HasBody() {
51 if err := c.Bind().Body(&payload); err == nil && payload.APIKey != "" {
52 return payload.APIKey
53 }
54 }
55
56 if err := c.Bind().Query(&payload); err != nil {
57 return ""
58 }
59
60 return payload.APIKey
61}

Callers 1

APIKeyAuthFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected