1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-28 08:47:55 +02:00

added support for @request.headers.*

This commit is contained in:
Gani Georgiev
2023-03-02 18:56:18 +02:00
parent 19faa0d8e7
commit a67c14c368
7 changed files with 41 additions and 9 deletions

View File

@@ -30,9 +30,18 @@ func RequestData(c echo.Context) *models.RequestData {
}
result := &models.RequestData{
Method: c.Request().Method,
Query: map[string]any{},
Data: map[string]any{},
Method: c.Request().Method,
Query: map[string]any{},
Data: map[string]any{},
Headers: map[string]string{},
}
// extract the first value of all headers and normalizes the keys
// ("X-Token" is converted to "x_token")
for k, v := range c.Request().Header {
if len(v) > 0 {
result.Headers[strings.ToLower(strings.ReplaceAll(k, "-", "_"))] = v[0]
}
}
result.AuthRecord, _ = c.Get(ContextAuthRecordKey).(*models.Record)