-
-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Description
As tested with Scala 3 and cask 0.7.11
Server definition
class ServerRoutes(using cask.Logger) extends cask.Routes:
@cask.get("/foo")
def foo() = "get foo!"
@cask.post("/bar")
def bar() = "post bar!"
initialize()
object server extends cask.Main:
val allRoutes = Seq(ServerRoutes())
Example queries with responses
> curl -D - 'localhost:8080/foo'
HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
Content-Length: 3
Date: Sun, 16 May 2021 19:57:13 GMT
get foo!
> curl -D - 'localhost:8080/bar'
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
Content-Length: 20
Date: Sun, 16 May 2021 19:57:16 GMT
Error 404: Not Found
> curl -D - -XPUT 'localhost:8080/baz'
HTTP/1.1 405 Method Not Allowed
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
Content-Length: 29
Date: Sun, 16 May 2021 19:57:24 GMT
Error 405: Method Not Allowed
Expected outcomes
Request -> response 1 is expected
Request -> response 2 should be 405 but is 404
Request -> response 3 should be 404 but is 405
Metadata
Metadata
Assignees
Labels
No labels