pass context as an argument

This commit is contained in:
2025-01-06 08:50:53 +03:00
parent 47b5ff0435
commit 974af6b2a7
6 changed files with 26 additions and 26 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

@@ -2,6 +2,7 @@ package http
import (
"bytes"
"context"
"errors"
"net/http"
"net/http/httptest"
@@ -161,7 +162,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)