mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-04-04 21:57:40 +03:00
Polish a little
This commit is contained in:
parent
21b27b5dbe
commit
bdeec4d297
5 changed files with 63 additions and 40 deletions
|
@ -1,6 +1,7 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"heckel.io/ntfy/util"
|
||||
"io"
|
||||
"net/http"
|
||||
|
@ -45,13 +46,6 @@ func readHeaderParam(r *http.Request, names ...string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func readHeaderParamValues(r *http.Request, names ...string) (values []string) {
|
||||
for _, name := range names {
|
||||
values = append(values, r.Header.Values(name)...)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func readQueryParam(r *http.Request, names ...string) string {
|
||||
for _, name := range names {
|
||||
value := r.URL.Query().Get(strings.ToLower(name))
|
||||
|
@ -103,3 +97,11 @@ func readJSONWithLimit[T any](r io.ReadCloser, limit int, allowEmpty bool) (*T,
|
|||
}
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
func withContext(r *http.Request, ctx map[contextKey]any) *http.Request {
|
||||
c := r.Context()
|
||||
for k, v := range ctx {
|
||||
c = context.WithValue(c, k, v)
|
||||
}
|
||||
return r.WithContext(c)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue