mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 14:26:58 +00:00
REMOVE fasthttp version
This commit is contained in:
parent
ea13ac0e92
commit
16a8d5d575
26 changed files with 331 additions and 1339 deletions
|
@ -1,11 +1,27 @@
|
|||
package html
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"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))
|
||||
}
|
||||
|
||||
func errorMessage(statusCode int) string {
|
||||
message := http.StatusText(statusCode)
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
//go:build fasthttp
|
||||
|
||||
package html
|
||||
|
||||
import (
|
||||
"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([]byte(errorBody(code)))
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
//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))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue