Skip to content

Conversation

@structwafel
Copy link
Contributor

I wanted to serve my index.html differently than the rest of my static files.
(to add a middleware on / )

After hours of pain, and trying other libraries. I thought an option was to have an ignore_files option.
That way you can ignore those files, and serve things how you want.

Perhaps there is a smarter way to setup my project, will try to play with it a bit to see if it is actually useful.


impl Parse for IgnoreFilesWithSpan {
fn parse(input: ParseStream) -> syn::Result<Self> {
let files = parse_dirs(input)?; // reuse parse_dirs since it's just parsing paths
Copy link
Member

Choose a reason for hiding this comment

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

NIT: should we rename parse_dirs into parse_paths?

Copy link
Member

@ThinkerDreamer ThinkerDreamer Sep 17, 2025

Choose a reason for hiding this comment

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

Yes, I think so. And the inner variables of the parse_dirs/parse_paths function should be renamed accordingly to avoid future confusion.
And after renaming the helper function @structwafel can remove the comment here, too.

let (parts, _) = response.into_parts();
assert!(parts.status.is_success());

// Request for index.html should return 404 since it's ignored
Copy link
Member

Choose a reason for hiding this comment

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

This should be app.js not index.html, right?

// app.js should be ignored, but styles.css should be available
assert!(router.has_routes());

// Request for app.js should succeed
Copy link
Member

Choose a reason for hiding this comment

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

And here app.js should be styles.css?

@ThinkerDreamer
Copy link
Member

Thanks a lot! I think it's a great addition. Once you change the name of the parse_dirs helper function and the variables in it, and remove the comment, plus reword your commits to use conventional commits (and fix the typo "explanation", not "explenation"), I would say this looks good!

@structwafel structwafel changed the title add ignore files option feat!: add ignore_paths parameter (replaces ignore_dirs) Sep 17, 2025
Copy link
Member

@paolobarbolini paolobarbolini left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the PR

@paolobarbolini paolobarbolini merged commit 7d2dd18 into M4SS-Code:main Sep 19, 2025
7 checks passed
@paolobarbolini
Copy link
Member

Released in v0.4.0

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.

3 participants