From c424021f186a1637c58493f6aa65230b9aa30901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ron=20Nosz=C3=A1ly?= Date: Fri, 6 Sep 2024 21:20:54 +0200 Subject: [PATCH] Respond with "400 BadRequest" if submission binding fails in judge Add static/ to .gitignore. --- .gitignore | 3 ++- internal/judge/server.go | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 03a6c185..ba0b0598 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ web.json judge.json web_prod.json -node_modules \ No newline at end of file +node_modules +static diff --git a/internal/judge/server.go b/internal/judge/server.go index 2870a3f2..da5cab58 100644 --- a/internal/judge/server.go +++ b/internal/judge/server.go @@ -4,6 +4,10 @@ import ( "encoding/json" "errors" "fmt" + "log/slog" + "net/http" + "time" + "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "github.com/mraron/njudge/pkg/language" @@ -13,9 +17,6 @@ import ( _ "github.com/mraron/njudge/pkg/problems/config/problem_yaml" _ "github.com/mraron/njudge/pkg/problems/config/task_yaml" slogecho "github.com/samber/slog-echo" - "log/slog" - "net/http" - "time" _ "github.com/mraron/njudge/pkg/language/langs/csharp" _ "github.com/mraron/njudge/pkg/language/langs/golang" @@ -73,7 +74,7 @@ func (s Server) PostJudgeHandler() echo.HandlerFunc { return func(c echo.Context) error { sub := Submission{} if err := c.Bind(&sub); err != nil { - return err + return echo.NewHTTPError(http.StatusBadRequest,err.Error()) } inited := false