Skip to content

Method handling #2

Description

@scossu

Thanks for this nifty little library.

I am testing out the server and I noticed that the methods advertised in the response do not match the route definition, e.g.

local mote = require "mote"

mote.get("/heartbeat", function(ctx)
    ctx.response.status = 200
    ctx.response.body = { message = "I am alive!" }
end)

local app = mote.create({ port = 5000 })
app:run()

Sending a request:

$ curl -iXPUT localhost:5000/heartbeat
HTTP/1.1 404 Not Found
Content-Type: application/json
Keep-Alive: timeout=5, max=1000
Connection: keep-alive
Content-Length: 21
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS

{"error":"not found"}

In this case I would expect the Access-Control-Allow-Methods to be set to GET (and HEAD if you want to stick with RFC 7231 and the response for PUT should be HTTP 405.

Good to see that HEAD works correctly (at least with curl).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions