mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-18 18:39:42 +00:00
19 lines
487 B
Go
19 lines
487 B
Go
//go:build !fasthttp
|
|
|
|
package html
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
|
|
"codeberg.org/codeberg/pages/server/context"
|
|
)
|
|
|
|
// ReturnErrorPage sets the response status code and writes NotFoundPage to the response body, with "%status" replaced
|
|
// with the provided status code.
|
|
func ReturnErrorPage(ctx *context.Context, code int) {
|
|
ctx.RespWriter.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
ctx.RespWriter.WriteHeader(code)
|
|
|
|
io.Copy(ctx.RespWriter, bytes.NewReader(errorBody(code)))
|
|
}
|