diff options
Diffstat (limited to 'worker/handlers.go')
| -rw-r--r-- | worker/handlers.go | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/worker/handlers.go b/worker/handlers.go deleted file mode 100644 index ac9701f..0000000 --- a/worker/handlers.go +++ /dev/null @@ -1,68 +0,0 @@ -package main - -import ( - "fmt" - "net/http" - - "github.com/labstack/echo/v4" -) - -func newBadRequestError(err error) *echo.HTTPError { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid request: %s", err.Error())) -} - -func handleSwiftCompile(c echo.Context) error { - var req swiftCompileRequestData - if err := c.Bind(&req); err != nil { - return newBadRequestError(err) - } - if err := req.validate(); err != nil { - return newBadRequestError(err) - } - - res := execSwiftCompile( - c.Request().Context(), - req.Code, - req.CodeHash, - req.maxDuration(), - ) - - return c.JSON(http.StatusOK, res) -} - -func handleWasmCompile(c echo.Context) error { - var req wasmCompileRequestData - if err := c.Bind(&req); err != nil { - return newBadRequestError(err) - } - if err := req.validate(); err != nil { - return newBadRequestError(err) - } - - res := execWasmCompile( - c.Request().Context(), - req.CodeHash, - req.maxDuration(), - ) - - return c.JSON(http.StatusOK, res) -} - -func handleTestRun(c echo.Context) error { - var req testRunRequestData - if err := c.Bind(&req); err != nil { - return newBadRequestError(err) - } - if err := req.validate(); err != nil { - return newBadRequestError(err) - } - - res := execTestRun( - c.Request().Context(), - req.CodeHash, - req.Stdin, - req.maxDuration(), - ) - - return c.JSON(http.StatusOK, res) -} |
