Beispiel #1
0
// getSwagger is the httprouter handle that returns the Swagger spec.
// func getSwagger(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
func getSwagger(ctx *goa.Context) error {
	ctx.Header().Set("Content-Type", "application/swagger+json")
	ctx.Header().Set("Cache-Control", "public, max-age=3600")
	return ctx.Respond(200, []byte(spec))
}
Beispiel #2
0
			Ω(rwo).ShouldNot(BeNil())
			Ω(rwo).Should(BeAssignableToTypeOf(&TestResponseWriter{}))
			trw := rwo.(*TestResponseWriter)
			Ω(trw.Status).Should(Equal(42))
		})
	})

	Describe("Request", func() {
		It("returns nil if not initialized", func() {
			Ω(ctx.Request()).Should(BeNil())
		})
	})

	Describe("Header", func() {
		It("returns nil if not initialized", func() {
			Ω(ctx.Header()).Should(BeNil())
		})
	})

	Describe("ResponseStatus", func() {
		It("returns 0 if not initialized", func() {
			Ω(ctx.ResponseStatus()).Should(Equal(0))
		})
	})

	Describe("ResponseLength", func() {
		It("returns 0 if not initialized", func() {
			Ω(ctx.ResponseLength()).Should(Equal(0))
		})
	})