Closed danboyle8637 closed 2 years ago
A DurableObject has a fetch
with the request
as parameter. I assume you would use it the same way as with workers.
import { Router } from 'itty-router'
class YourClass {
async fetch(request) {
const router = Router()
router.get('*', () => new Response('Hello'))
return router.handle(request)
}
}
You're basically on the right track!
Check out the code behind itty-durable to see what I did, but basically I embed a router (itty) into the durable, then intercept fetch requests.
Closing the issue to avoid getting dinged, but feel free to continue the dialog here! :)
@kwhitley did not know about itty-durable
that's great!!
I saw an interview with you and you mentioned you were using itty router in a durable object class.
How?
I can't seem to get it to work... but I'm also a little brain dead at this point with dealing with all the DO issues. haha... thanks for any insight.