Files
acme-dns/vendor/github.com/gavv/httpexpect/_examples/fasthttp.go
2018-01-22 11:19:33 +02:00

24 lines
450 B
Go

package examples
import (
"github.com/valyala/fasthttp"
)
// FastHTTPHandler creates fasthttp.RequestHandler.
//
// Routes:
// GET /ping return "pong"
func FastHTTPHandler() fasthttp.RequestHandler {
return func(ctx *fasthttp.RequestCtx) {
switch string(ctx.Path()) {
case "/ping":
ctx.SetStatusCode(fasthttp.StatusOK)
ctx.SetContentType("text/plain")
ctx.SetBody([]byte("pong"))
default:
panic("unsupported path")
}
}
}