Skip to content

Commit

Permalink
Reopen the Request handler
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed Apr 29, 2021
1 parent 4c94f56 commit f87b2bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ func (r *Request) WithHandler(handler func(r *http.Request) ([]byte, error)) *Re
return r
}

// Handle handles the HTTP request.
func (r *Request) Handle(req *http.Request) ([]byte, error) {
return r.handle(req)
}

// Once indicates that the mock should only return the value once.
//
// Server.Expect(http.MethodGet, "/path").
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {

w.WriteHeader(expected.StatusCode)

body, err := expected.handle(r)
body, err := expected.Handle(r)
require.NoError(s.test, err)

_, err = w.Write(body)
Expand Down

0 comments on commit f87b2bd

Please sign in to comment.