Esempio n. 1
0
func main() {

	port := flag.Int("p", 8080, "http port")
	flag.Parse()

	pprofMux := http.NewServeMux()
	registerPProf(pprofMux.HandleFunc)
	fastpprof := fasthttpadaptor.NewFastHTTPHandler(pprofMux)

	requestHandler := func(ctx *fasthttp.RequestCtx) {
		switch {
		case bytes.Equal(ctx.Path(), []byte("/debug/pprof")):
			ctx.Redirect("/debug/pprof/", 301)
		case bytes.HasPrefix(ctx.Path(), []byte("/debug/pprof/")):
			fastpprof(ctx)
		default:
			ctx.NotFound()
		}
	}

	log.Println("listening on port", *port)

	err := fasthttp.ListenAndServe(":"+strconv.Itoa(*port), requestHandler)
	if err != nil {
		log.Println("error during fasthttp.ListenAndServe(): ", err)
	}
}
Esempio n. 2
0
func TestExpectBasicHandlerBinderFast(t *testing.T) {
	handler := fasthttpadaptor.NewFastHTTPHandler(createBasicHandler())

	testBasicHandler(WithConfig(Config{
		BaseURL:  "http://example.com",
		Reporter: NewAssertReporter(t),
		Client: &http.Client{
			Transport: NewFastBinder(handler),
		},
	}))
}
Esempio n. 3
0
func TestExpectCookieHandlerBinderFastEnabled(t *testing.T) {
	handler := fasthttpadaptor.NewFastHTTPHandler(createCookieHandler())

	e := WithConfig(Config{
		BaseURL:  "http://example.com",
		Reporter: NewAssertReporter(t),
		Client: &http.Client{
			Transport: NewFastBinder(handler),
			Jar:       NewJar(),
		},
	})

	testCookieHandler(e, true)
}