Merge branch 'lash/purify-more' into lash/purify-max

This commit is contained in:
lash
2025-01-06 08:38:05 +00:00
13 changed files with 604 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
package http
import (
"context"
"io/ioutil"
"net/http"
@@ -10,7 +11,7 @@ import (
type DefaultRequestParser struct {
}
func (rp *DefaultRequestParser) GetSessionId(rq any) (string, error) {
func (rp *DefaultRequestParser) GetSessionId(ctx context.Context, rq any) (string, error) {
rqv, ok := rq.(*http.Request)
if !ok {
return "", handlers.ErrInvalidRequest
@@ -34,5 +35,3 @@ func (rp *DefaultRequestParser) GetInput(rq any) ([]byte, error) {
}
return v, nil
}

View File

@@ -40,7 +40,7 @@ func (f *SessionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
rp := f.GetRequestParser()
cfg := f.GetConfig()
cfg.SessionId, err = rp.GetSessionId(req)
cfg.SessionId, err = rp.GetSessionId(req.Context(), req)
if err != nil {
logg.ErrorCtxf(rqs.Ctx, "", "header processing error", err)
f.WriteError(w, 400, err)

View File

@@ -2,6 +2,7 @@ package http
import (
"bytes"
"context"
"errors"
"net/http"
"net/http/httptest"
@@ -165,7 +166,7 @@ func TestDefaultRequestParser_GetSessionId(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
id, err := parser.GetSessionId(tt.request)
id, err := parser.GetSessionId(context.Background(),tt.request)
if id != tt.expectedID {
t.Errorf("Expected session ID %s, got %s", tt.expectedID, id)