mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-30 01:53:34 +02:00
23 lines
535 B
Go
23 lines
535 B
Go
//go:build !fasthttp
|
|
|
|
package html
|
|
|
|
import (
|
|
"io"
|
|
"strings"
|
|
|
|
"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, msg string, code int) {
|
|
ctx.RespWriter.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
ctx.RespWriter.WriteHeader(code)
|
|
|
|
if msg == "" {
|
|
msg = errorBody(code)
|
|
}
|
|
|
|
io.Copy(ctx.RespWriter, strings.NewReader(msg))
|
|
}
|