Rename session handler to request handler
This commit is contained in:
		
							parent
							
								
									ca29574a9d
								
							
						
					
					
						commit
						b602a6d9a0
					
				| @ -14,18 +14,18 @@ var ( | ||||
| 	logg = logging.NewVanilla().WithDomain("atserver") | ||||
| ) | ||||
| 
 | ||||
| type ATSessionHandler struct { | ||||
| 	//*httpsession.SessionHandler
 | ||||
| type ATRequestHandler struct { | ||||
| 	//*httpsession.RequestHandler
 | ||||
| 	request.RequestHandler | ||||
| } | ||||
| 
 | ||||
| func NewATSessionHandler(h request.RequestHandler) *ATSessionHandler { | ||||
| 	return &ATSessionHandler{ | ||||
| func NewATRequestHandler(h request.RequestHandler) *ATRequestHandler { | ||||
| 	return &ATRequestHandler{ | ||||
| 		RequestHandler: h, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (ash *ATSessionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { | ||||
| func (ash *ATRequestHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { | ||||
| 	var code int | ||||
| 	var err error | ||||
| 
 | ||||
| @ -80,7 +80,7 @@ func (ash *ATSessionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (ash *ATSessionHandler) Output(rqs request.RequestSession) (request.RequestSession, error) { | ||||
| func (ash *ATRequestHandler) Output(rqs request.RequestSession) (request.RequestSession, error) { | ||||
| 	var err error | ||||
| 	var prefix string | ||||
| 
 | ||||
| @ -99,7 +99,7 @@ func (ash *ATSessionHandler) Output(rqs request.RequestSession) (request.Request | ||||
| 	return rqs, err | ||||
| } | ||||
| 
 | ||||
| func (ash *ATSessionHandler) WriteError(w http.ResponseWriter, code int, err error) { | ||||
| func (ash *ATRequestHandler) WriteError(w http.ResponseWriter, code int, err error) { | ||||
| 	s := err.Error() | ||||
| 	w.Header().Set("Content-Length", strconv.Itoa(len(s))) | ||||
| 	w.WriteHeader(code) | ||||
|  | ||||
| @ -16,20 +16,20 @@ import ( | ||||
| 	"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks/httpmocks" | ||||
| ) | ||||
| 
 | ||||
| //func TestNewATSessionHandler(t *testing.T) {
 | ||||
| //func TestNewATRequestHandler(t *testing.T) {
 | ||||
| //	mockHandler := &httpmocks.MockRequestHandler{}
 | ||||
| //	ash := NewATSessionHandler(mockHandler)
 | ||||
| //	ash := NewATRequestHandler(mockHandler)
 | ||||
| //
 | ||||
| //	if ash == nil {
 | ||||
| //		t.Fatal("NewATSessionHandler returned nil")
 | ||||
| //		t.Fatal("NewATRequestHandler returned nil")
 | ||||
| //	}
 | ||||
| //
 | ||||
| //	if ash.HTTPRequestHandler == nil {
 | ||||
| //		t.Fatal("SessionHandler is nil")
 | ||||
| //		t.Fatal("RequestHandler is nil")
 | ||||
| //	}
 | ||||
| //}
 | ||||
| 
 | ||||
| func TestATSessionHandler_ServeHTTP(t *testing.T) { | ||||
| func TestATRequestHandler_ServeHTTP(t *testing.T) { | ||||
| 	tests := []struct { | ||||
| 		name           string | ||||
| 		setupMocks     func(*httpmocks.MockRequestHandler, *httpmocks.MockRequestParser, *httpmocks.MockEngine) | ||||
| @ -137,7 +137,7 @@ func TestATSessionHandler_ServeHTTP(t *testing.T) { | ||||
| 			mockEngine := &httpmocks.MockEngine{} | ||||
| 			tt.setupMocks(mockHandler, mockRequestParser, mockEngine) | ||||
| 
 | ||||
| 			ash := NewATSessionHandler(mockHandler) | ||||
| 			ash := NewATRequestHandler(mockHandler) | ||||
| 
 | ||||
| 			req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(tt.formData.Encode())) | ||||
| 			req.Header.Set("Content-Type", "application/x-www-form-urlencoded") | ||||
| @ -156,7 +156,7 @@ func TestATSessionHandler_ServeHTTP(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func TestATSessionHandler_Output(t *testing.T) { | ||||
| func TestATRequestHandler_Output(t *testing.T) { | ||||
| 	tests := []struct { | ||||
| 		name           string | ||||
| 		input          request.RequestSession | ||||
| @ -209,7 +209,7 @@ func TestATSessionHandler_Output(t *testing.T) { | ||||
| 
 | ||||
| 	for _, tt := range tests { | ||||
| 		t.Run(tt.name, func(t *testing.T) { | ||||
| 			ash := &ATSessionHandler{} | ||||
| 			ash := &ATRequestHandler{} | ||||
| 			_, err := ash.Output(tt.input) | ||||
| 
 | ||||
| 			if tt.expectedError && err == nil { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user