mirror of
https://github.com/acme-dns/acme-dns.git
synced 2026-02-26 14:03:20 -07:00
24 lines
450 B
Go
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")
|
|
}
|
|
}
|
|
}
|