-
Notifications
You must be signed in to change notification settings - Fork 5
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
src: use itty-router for routing requests #125
base: main
Are you sure you want to change the base?
Conversation
cc @ovflowd |
468abd1
to
6073527
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review! Going to review more later :)
}); | ||
} | ||
|
||
function getR2Path({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt these be handled by itty router why path regular expressions? Ie:
/some/path/{something}/some/other/matcher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are handling parts of the path with itty router here, but that just pulls out some info from the path so that we can use it later.
We still need to take the relevant parts and make the path in the r2 bucket, which is what this function does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use itty router again for that? Like a layered strategy?
So an in-router router? Because that is the part I really wish to become "easy to handle" by just using itty-router
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe? I'm not really sure what that would look like
I think with this approach we're still better off though. It's still a tiny bit messy but a lot more understandable than what we have now and would probably be simpler than having an in-router router imo
I also debated doing something like
router.get('/:rootPath/?:path+', [cached(r2Middleware), originMiddleware]);
that way we can just use a switch statement in getR2Path, which might help with cleaning it up. Performance wise it should be about the same. Might cause some annoyances if we want to add other GET paths to the worker later down the road though
9536911
to
7feed9d
Compare
src/constants/r2Prefixes.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should build still be on the codeowners for this file?
faea803
to
16c0b7b
Compare
Closes #122 Signed-off-by: flakey5 <[email protected]>
16c0b7b
to
7f20585
Compare
Closes #122
Closes #106
Closes #111
TODO