Skip to content
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

Granular route matching #2464

Merged
merged 1 commit into from
Apr 29, 2024
Merged

Conversation

itowlson
Copy link
Contributor

@itowlson itowlson commented Apr 22, 2024

Fixes #1923.

This is WIP, pushed for squigglies if I break the integration tests. It's not yet ready for review.

This uses routefinder syntax, except we still allow /... for the trailing wildcard. E.g. /users/:userid/notes/....

The trailing wildcard goes in the spin-path-info header, as it does today. Named segment wildcards go in headers along the lines of spin-path-match-<name> e.g. spin-path-match-userid. Feel free to suggest better ideas: I kind of did the first thing I thought of because I knew you reprobates would bikeshed it anyway. grin

I am not 100% comfortable with the test coverage, but am not sure what else I can meaningfully add. I'd welcome feedback or suggestions!

Thanks again to @lann and @fibonacci1729 for getting me off an unproductive design and onto this one!

@itowlson itowlson force-pushed the fancy-schmancy-routes-2 branch 5 times, most recently from 6f6128a to c118079 Compare April 28, 2024 22:20
@itowlson itowlson marked this pull request as ready for review April 28, 2024 22:51
Copy link
Collaborator

@lann lann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/nit comments; impl looks good

crates/llm-local/src/lib.rs Outdated Show resolved Hide resolved
client_addr: SocketAddr,
) -> Result<Vec<(&'a [&'a str], String)>> {
) -> Result<Vec<([Cow<'static, str>; 2], String)>> {
const fn cowed(strs: &[&'static str; 2]) -> [Cow<'static, str>; 2] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FRIGHTEN THE VARIABLES INTO COMPLIANCE WITH YOUR TYPES

client_addr: SocketAddr,
) -> Result<Vec<(&'a [&'a str], String)>> {
) -> Result<Vec<([Cow<'static, str>; 2], String)>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would return Strings here. Avoiding allocations is nice and all but all these headers get rewritten a couple of times downstream anyway; probably not worth the extra complexity here.

crates/trigger-http/src/lib.rs Outdated Show resolved Hide resolved
Signed-off-by: itowlson <[email protected]>
@itowlson itowlson merged commit 3bd74a2 into fermyon:main Apr 29, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for more granular route matching in Spin
3 participants