Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cask returns 405 for an undefined route that uses a method not used by other routes. #51

Closed
megri opened this issue May 16, 2021 · 0 comments · Fixed by #52
Closed

Cask returns 405 for an undefined route that uses a method not used by other routes. #51

megri opened this issue May 16, 2021 · 0 comments · Fixed by #52

Comments

@megri
Copy link
Contributor

megri commented May 16, 2021

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

megri added a commit to megri/cask that referenced this issue May 18, 2021
Fixes com-lihaoyi#51.

Prior to this commit, `prepareRouteTries` created a mapping from
method-name to DispatchTrie (Map[String, DispatchTrie[…]]).

This commit instead creates a DispatchTrie[Map[String, …]],
basically an inversion of the previous result.

The updated tests in minimalApplication and minimalApplication2
have been updated to cover the differences.
megri added a commit to megri/cask that referenced this issue May 18, 2021
Fixes com-lihaoyi#51.

Prior to this commit, `prepareRouteTries` created a mapping from
method-name to DispatchTrie (Map[String, DispatchTrie[…]]).

This commit instead creates a DispatchTrie[Map[String, …]],
basically an inversion of the previous result.

The updated tests in minimalApplication and minimalApplication2
have been updated to cover the differences.
megri added a commit to megri/cask that referenced this issue May 18, 2021
Fixes com-lihaoyi#51.

Prior to this commit, `prepareRouteTries` created a mapping from
method-name to DispatchTrie (Map[String, DispatchTrie[…]]).

This commit instead creates a DispatchTrie[Map[String, …]],
basically an inversion of the previous result.

The updated tests in minimalApplication and minimalApplication2
have been updated to cover the differences.
megri added a commit to megri/cask that referenced this issue May 18, 2021
Fixes com-lihaoyi#51.

Prior to this commit, `prepareRouteTries` created a mapping from
method-name to DispatchTrie (Map[String, DispatchTrie[…]]).

This commit instead creates a DispatchTrie[Map[String, …]],
basically an inversion of the previous result.

The updated tests in minimalApplication and minimalApplication2
have been updated to cover the differences.
megri added a commit to megri/cask that referenced this issue May 18, 2021
Fixes com-lihaoyi#51.

Prior to this commit, `prepareRouteTries` created a mapping from
method-name to DispatchTrie (Map[String, DispatchTrie[…]]).

This commit instead creates a DispatchTrie[Map[String, …]],
basically an inversion of the previous result.

The updated tests in minimalApplication and minimalApplication2
have been updated to cover the differences.
megri added a commit to megri/cask that referenced this issue May 18, 2021
Fixes com-lihaoyi#51.

Prior to this commit, `prepareRouteTries` created a mapping from
method-name to DispatchTrie (Map[String, DispatchTrie[…]]).

This commit instead creates a DispatchTrie[Map[String, …]],
basically an inversion of the previous result.

The updated tests in minimalApplication and minimalApplication2
have been updated to cover the differences.
lihaoyi pushed a commit that referenced this issue Nov 15, 2021
…5 responses. (#52)

Prevent cask from responding with 405 for an undefined route.
Fixes #51.

Prior to this commit, `prepareRouteTries` created a mapping from
method-name to DispatchTrie (Map[String, DispatchTrie[…]]).

This commit instead creates a DispatchTrie[Map[String, …]],
basically an inversion of the previous result.

The updated tests in minimalApplication and minimalApplication2
have been updated to cover the differences.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant