1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package meta
import (
"shrine/types/hypertext"
"github.com/gofiber/fiber/v2"
)
func findParam(params []hypertext.Param, key string) (string, bool) {
for _, param := range params {
if param.Key == key {
return param.Value, true
}
}
return "", false
}
func buildQueryParams(context *fiber.Ctx) []hypertext.Param {
params := make([]hypertext.Param, 0)
context.Request().URI().QueryArgs().VisitAll(func(name, value []byte) {
params = append(params, hypertext.Param{
Key: string(name),
Value: string(value),
})
})
return params
}
func buildRouteParams(context *fiber.Ctx) []hypertext.Param {
params := make([]hypertext.Param, 0)
for name, value := range context.AllParams() {
params = append(params, hypertext.Param{
Key: name,
Value: value,
})
}
return params
}
func buildHeaders(context *fiber.Ctx) []hypertext.Param {
params := make([]hypertext.Param, 0)
context.Request().Header.VisitAll(func(name, value []byte) {
params = append(params, hypertext.Param{
Key: string(name),
Value: string(value),
})
})
return params
}
|