Skip to content

Commit

Permalink
Respond with "400 BadRequest" if submission binding fails in judge
Browse files Browse the repository at this point in the history
Add static/ to .gitignore.
  • Loading branch information
mraron committed Sep 6, 2024
1 parent ccf1a23 commit c424021
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
web.json
judge.json
web_prod.json
node_modules
node_modules
static
9 changes: 5 additions & 4 deletions internal/judge/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c424021

Please sign in to comment.