Skip to content

Commit c424021

Browse files
committed
Respond with "400 BadRequest" if submission binding fails in judge
Add static/ to .gitignore.
1 parent ccf1a23 commit c424021

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
web.json
33
judge.json
44
web_prod.json
5-
node_modules
5+
node_modules
6+
static

internal/judge/server.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7+
"log/slog"
8+
"net/http"
9+
"time"
10+
711
"github.com/labstack/echo/v4"
812
"github.com/labstack/echo/v4/middleware"
913
"github.com/mraron/njudge/pkg/language"
@@ -13,9 +17,6 @@ import (
1317
_ "github.com/mraron/njudge/pkg/problems/config/problem_yaml"
1418
_ "github.com/mraron/njudge/pkg/problems/config/task_yaml"
1519
slogecho "github.com/samber/slog-echo"
16-
"log/slog"
17-
"net/http"
18-
"time"
1920

2021
_ "github.com/mraron/njudge/pkg/language/langs/csharp"
2122
_ "github.com/mraron/njudge/pkg/language/langs/golang"
@@ -73,7 +74,7 @@ func (s Server) PostJudgeHandler() echo.HandlerFunc {
7374
return func(c echo.Context) error {
7475
sub := Submission{}
7576
if err := c.Bind(&sub); err != nil {
76-
return err
77+
return echo.NewHTTPError(http.StatusBadRequest,err.Error())
7778
}
7879

7980
inited := false

0 commit comments

Comments
 (0)