summary refs log tree commit diff
path: root/handlers/handler.go
diff options
context:
space:
mode:
authorMelonai <einebeere@gmail.com>2021-07-26 22:37:37 +0200
committerMelonai <einebeere@gmail.com>2021-07-26 22:37:37 +0200
commit83a8214119eccb39f4c38e7b1ae54daebdeb0184 (patch)
tree064be9c76e295985634718cb290d8acb1cd2dada /handlers/handler.go
parent0ac82c133b78a14239beb9034380c44d95d4bad3 (diff)
downloadportgate-83a8214119eccb39f4c38e7b1ae54daebdeb0184.tar.zst
portgate-83a8214119eccb39f4c38e7b1ae54daebdeb0184.zip
Prefer high-level RequestCtx functions over low-level ones
Diffstat (limited to 'handlers/handler.go')
-rw-r--r--handlers/handler.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/handlers/handler.go b/handlers/handler.go
index 56801a3..d6e1b5b 100644
--- a/handlers/handler.go
+++ b/handlers/handler.go
@@ -76,6 +76,11 @@ func (h *RequestHandler) HandleRequest(ctx *fasthttp.RequestCtx) {
 // information.
 func (h *RequestHandler) handleUnknownRequest(ctx *fasthttp.RequestCtx) {
 	// TODO: Show error page
-	ctx.SetStatusCode(http.StatusNotFound)
-	_, _ = ctx.WriteString("Unknown request.")
+	ctx.Error("Unknown request.", http.StatusNotFound)
+}
+
+// handleUnknownRequest handles errors which occurred during a request with a generic message.
+func (h *RequestHandler) handleError(ctx *fasthttp.RequestCtx) {
+	// TODO: Show error page
+	ctx.Error("An error occurred", http.StatusInternalServerError)
 }