Beispiel #1
0
func MakeTestContextWithDetails(path, method string) *webcontext.WebContext {

	TestCodecService = new(codecservices.WebCodecService)
	TestResponseWriter = new(http_test.TestResponseWriter)
	TestRequest, _ = http.NewRequest(method, fmt.Sprintf("http://stretchr.org/%s", path), nil)

	return webcontext.NewWebContext(TestResponseWriter, TestRequest, TestCodecService)
}
Beispiel #2
0
// ServeHTTP servers the actual HTTP request by buidling a context and running
// it through all the handlers.
func (handler *HttpHandler) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request) {

	// make the context
	ctx := webcontext.NewWebContext(responseWriter, request, handler.codecService)

	// run it through the handlers
	_, err := handler.Handlers.Handle(ctx)

	// do we need to handle an error?
	if err != nil {

		// set the error
		ctx.Data().Set(DataKeyForError, err)

		// tell the handler to handle it
		handler.ErrorHandler().Handle(ctx)

	}

}