From 9234e883e6eab05abc9fa7d5df3f8b21adb996f3 Mon Sep 17 00:00:00 2001 From: sneak Date: Sat, 4 Apr 2020 18:37:30 -0700 Subject: [PATCH] factor out 404 handler so all 404s are the same --- process/handlers.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/process/handlers.go b/process/handlers.go index 48acf0f..972d9c0 100644 --- a/process/handlers.go +++ b/process/handlers.go @@ -88,6 +88,10 @@ func (a *Server) getInstanceListHandler() http.HandlerFunc { } */ +func (a *Server) notFoundHandler(c echo.Context) error { + return c.String(http.StatusNotFound, "404 not found") +} + func (a *Server) instanceHandler(c echo.Context) error { tu := c.Param("uuid") u, err := uuid.Parse(tu) @@ -103,6 +107,12 @@ func (a *Server) instanceHandler(c echo.Context) error { } } + _, exists := tc["instance"] + + if !exists { + return a.notFoundHandler(c) + } + return c.Render(http.StatusOK, "instance.html", tc) }