ctrl := service.NewController("test") service.ServeMux().Handle(method, path, ctrl.HandleFunc("", h)) service.ServeMux().Handle("OPTIONS", path, ctrl.HandleFunc("", optionsHandler)) cors.MountPreflightController(service, spec) portIndex++ port := 54511 + portIndex url = fmt.Sprintf("http://localhost:%d", port) go service.ListenAndServe(fmt.Sprintf(":%d", port)) // ugh - does anyone have a better idea? we need to wait for the server // to start listening or risk tests failing because sendind requests too // early. time.Sleep(time.Duration(100) * time.Millisecond) }) AfterEach(func() { service.Shutdown() }) Context("handling GET requests", func() { BeforeEach(func() { method = "GET" path = "/" }) It("responds", func() { resp, err := http.Get(url) Ω(err).ShouldNot(HaveOccurred()) Ω(resp.StatusCode).Should(Equal(200)) }) Context("using CORS that allows the request", func() {