Skip to content

Method handling #2

Closed
Closed

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).

Activity

  1. self-assigned this
    on Mar 21, 2026
  2. added 5 commits that reference this issue on Mar 22, 2026
    954225e
    c003e1f
    376a339
    c1e0527
    161e591
  3. added a commit that references this issue on Mar 22, 2026
    394aafc
  4. pgagnidze commented on Mar 22, 2026

    @pgagnidze
    Member

    Thanks for reporting this, @scossu! Both issues are fixed in #3:

    • PUT /heartbeat now returns 405 Method Not Allowed with Allow: GET, OPTIONS
    • OPTIONS /heartbeat preflight now returns Access-Control-Allow-Methods: GET, OPTIONS (scoped to the path, not global)
    • Unmatched paths still return 404 as expected

    The fix will be available on LuaRocks once v0.1.7 is tagged.

  5. scossu commented on Mar 22, 2026

    @scossu
    Author

    Thanks for the quick fix @pgagnidze .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions