diff --git a/cmd/http/main.go b/cmd/http/main.go index 1fd9574..eb2aa19 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -21,7 +21,6 @@ import ( httpserver "git.grassecon.net/urdt/ussd/internal/http" "git.grassecon.net/urdt/ussd/internal/storage" "git.grassecon.net/urdt/ussd/remote" - "git.grassecon.net/urdt/ussd/request" ) var ( @@ -124,7 +123,11 @@ func main() { rp := &httpserver.DefaultRequestParser{} bsh := handlers.NewBaseSessionHandler(cfg, rs, stateStore, userdataStore, rp, hl) - sh := request.ToSessionHandler(bsh) + // TODO: less hacky way of making session handler + //sh := request.ToSessionHandler(bsh) + sh := &httpserver.SessionHandler{ + RequestHandler: bsh, + } s := &http.Server{ Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))), Handler: sh, diff --git a/internal/http/server_test.go b/internal/http/server_test.go index 2a63f9c..c7b5f33 100644 --- a/internal/http/server_test.go +++ b/internal/http/server_test.go @@ -98,7 +98,10 @@ func TestSessionHandler_ServeHTTP(t *testing.T) { }, } - sessionHandler := request.ToSessionHandler(mockRequestHandler) + sessionHandler := &SessionHandler{ + RequestHandler: mockRequestHandler, + } + //sessionHandler := request.ToSessionHandler(mockRequestHandler) req := httptest.NewRequest(http.MethodPost, "/", bytes.NewBuffer(tt.input)) req.Header.Set("X-Vise-Session", tt.sessionID) diff --git a/request/request.go b/request/request.go index dc400c5..3a7d678 100644 --- a/request/request.go +++ b/request/request.go @@ -2,7 +2,6 @@ package request import ( "context" - "fmt" "io" "net/http" "strconv" @@ -59,10 +58,6 @@ func (f *SessionHandler) WriteError(w http.ResponseWriter, code int, err error) } } -func (f *SessionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { - f.WriteError(w, 500, fmt.Errorf("not implemented")) -} - func ToSessionHandler(h RequestHandler) *SessionHandler { return &SessionHandler{ RequestHandler: h,