コード例 #1
0
ファイル: proxy.go プロジェクト: cloudfoundry/gorouter
// ServeHTTP wraps the responseWriter in a ProxyResponseWriter
func (p *proxyWriterHandler) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request, next http.HandlerFunc) {
	proxyWriter := utils.NewProxyResponseWriter(responseWriter)
	next(proxyWriter, request)
}
コード例 #2
0
	nextHandler := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
		_, err := ioutil.ReadAll(req.Body)
		Expect(err).NotTo(HaveOccurred())

		rw.WriteHeader(http.StatusTeapot)
		rw.Write([]byte("I'm a little teapot, short and stout."))

		nextCalled = true
	})

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("zipkin")
		body := bytes.NewBufferString("What are you?")
		req = test_util.NewRequest("GET", "example.com", "/", body)
		resp = httptest.NewRecorder()
		proxyWriter = utils.NewProxyResponseWriter(resp)

		extraHeadersToLog = []string{}

		accessLogger = &fakes.FakeAccessLogger{}

		handler = handlers.NewAccessLog(accessLogger, &extraHeadersToLog)

		nextCalled = false
	})

	AfterEach(func() {
		Expect(nextCalled).To(BeTrue(), "Expected the next handler to be called.")
	})

	It("sets an access log record on the context", func() {