Closed aligzl closed 2 years ago
I'd need to see entire code here, because that's exactly what itty does handle (and it has heavy test coverage to verify/ensure it).
A couple things:
post
attribute on the request coming from? I assume it comes from somewhere upstream in your code?heads
bit pseudocode replacement of actual headers? That won't work either...
import { Router } from 'itty-router'
import { json, text, withContent, withParams } from 'itty-router-extras'
const router = Router()
router
.post('/somewhere', withContent, ({ content }) => json(content)) // withContent embeds parsed POST body, and json returns JSON response
.post('/somewhere/:id', withContent, withParams, ({ content, id }) => // withParams embeds params directly on request
text(post saved to id ${id} with content length of ${content.length}
) // text() returns text response
)
.all('*', request => missing(Cannot find a path for ${request.url}
)) // missing returns 404 response
This test in the spec covers your exact scenario!
Going to label this as not a bug unless we can find something for sure amiss!
Closing this unless more info can be added to reopen! Just let me know!
I have tried to build rest api with cloudflare workers. I have fallowing routes
When i sent request to the rooms/:id it takes care of rooms/image. Router does not get correct route releated to regex.