Skip to content

Make ServieFile specialized version of ServeDir#187

Merged
davidpdrsn merged 4 commits intomasterfrom
merge-serve-dir-and-file
Nov 24, 2021
Merged

Make ServieFile specialized version of ServeDir#187
davidpdrsn merged 4 commits intomasterfrom
merge-serve-dir-and-file

Conversation

@Nehliin
Copy link
Copy Markdown
Collaborator

@Nehliin Nehliin commented Nov 23, 2021

Motivation

Fixes: #184 and reduces the need to implement features twice in both ServeFile and ServeDir.

Solution

This implementaiton specializes ServeDir to avoid unnecessary overhead for the ServeFile usecase. ServeFile now simply wraps a ServeDir service.

@Nehliin Nehliin requested a review from davidpdrsn November 23, 2021 10:14
@Nehliin Nehliin force-pushed the merge-serve-dir-and-file branch from 5cfa005 to a964ccb Compare November 24, 2021 08:16
Comment on lines +105 to +112
enum ServeVariant {
Directory {
append_index_html_on_directories: bool,
},
SingleFile {
mime: HeaderValue,
},
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a great idea! Much simpler than the design I had in mind 👍

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks!

@davidpdrsn davidpdrsn merged commit 1069c2e into master Nov 24, 2021
@davidpdrsn davidpdrsn deleted the merge-serve-dir-and-file branch November 24, 2021 13:08
@c5soft
Copy link
Copy Markdown
Contributor

c5soft commented Nov 25, 2021

Nice! I have to give up my implementation, and I have recompiled one of my production project with the new code, it works perfectly.

@davidpdrsn davidpdrsn mentioned this pull request Dec 1, 2021
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.

Implement ServeFile in terms of ServeDir

3 participants