mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-29 09:33:36 +02:00
27 lines
589 B
Go
27 lines
589 B
Go
package html
|
|
|
|
import (
|
|
"bytes"
|
|
"net/http"
|
|
"strconv"
|
|
)
|
|
|
|
func errorMessage(statusCode int) string {
|
|
message := http.StatusText(statusCode)
|
|
|
|
switch statusCode {
|
|
case http.StatusMisdirectedRequest:
|
|
message += " - domain not specified in <code>.domains</code> file"
|
|
case http.StatusFailedDependency:
|
|
message += " - target repo/branch doesn't exist or is private"
|
|
}
|
|
|
|
return message
|
|
}
|
|
|
|
// TODO: use template engine?
|
|
func errorBody(statusCode int) []byte {
|
|
return bytes.ReplaceAll(NotFoundPage,
|
|
[]byte("%status"),
|
|
[]byte(strconv.Itoa(statusCode)+" "+errorMessage(statusCode)))
|
|
}
|