summaryrefslogtreecommitdiff
path: root/internal/middleware/headerfilter.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-09-04 14:43:36 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-09-04 14:43:36 +0200
commit5a54e7156b8e64edaf85bab74fbf2b65bcc65a13 (patch)
treec3419fd5b26295147ee13f881dfaae6cf59a818e /internal/middleware/headerfilter.go
parentstyle: add a missing whitespace (#4404) (diff)
downloadgotosocial-5a54e7156b8e64edaf85bab74fbf2b65bcc65a13.tar.xz
[performance] faster request id generation (#4405)
This uses a much faster method of generating request IDs using an atomically updated counter instead of a mutex lock and read of /dev/random. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4405 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/middleware/headerfilter.go')
-rw-r--r--internal/middleware/headerfilter.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/internal/middleware/headerfilter.go b/internal/middleware/headerfilter.go
index 0fd2a8877..38c6f6225 100644
--- a/internal/middleware/headerfilter.go
+++ b/internal/middleware/headerfilter.go
@@ -53,7 +53,10 @@ func HeaderFilter(state *state.State) gin.HandlerFunc {
}
func headerFilterAllowMode(state *state.State) func(c *gin.Context) {
- _ = *state //nolint
+ if state == nil {
+ panic(gtserror.New("nil check elimination"))
+ }
+
// Allowlist mode: explicit block takes
// precedence over explicit allow.
//
@@ -93,7 +96,10 @@ func headerFilterAllowMode(state *state.State) func(c *gin.Context) {
}
func headerFilterBlockMode(state *state.State) func(c *gin.Context) {
- _ = *state //nolint
+ if state == nil {
+ panic(gtserror.New("nil check elimination"))
+ }
+
// Blocklist/default mode: explicit allow
// takes precedence over explicit block.
//