mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-10-01 04:13:41 +00:00
21 lines
482 B
Go
21 lines
482 B
Go
|
//go:build fasthttp
|
||
|
|
||
|
package html
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"strconv"
|
||
|
|
||
|
"github.com/valyala/fasthttp"
|
||
|
)
|
||
|
|
||
|
// ReturnErrorPage sets the response status code and writes NotFoundPage to the response body, with "%status" replaced
|
||
|
// with the provided status code.
|
||
|
func ReturnErrorPage(ctx *fasthttp.RequestCtx, code int) {
|
||
|
ctx.Response.SetStatusCode(code)
|
||
|
ctx.Response.Header.SetContentType("text/html; charset=utf-8")
|
||
|
|
||
|
// TODO: use template engine?
|
||
|
ctx.Response.SetBody(errorBody(code))
|
||
|
}
|