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

feat: read static files from the public folder #29

Merged
merged 5 commits into from
Nov 15, 2022

Conversation

Angelmmiguel
Copy link
Contributor

Support static files by reading them from the public folder in the root of the project. Any file inside this folder will be served as a static file, so project like static sites can work without embedding files in the workers. This is a pretty consistent standard in different web frameworks like:

Note that the public folder based on the given path in the CLI. So, for wws ./examples, the CLI will serve the files from ./examples/public. There's an issue with path management as wws ./examples should calculate the routes without including the examples folder. This issue will be solved in #3.

It closes #7

@Angelmmiguel
Copy link
Contributor Author

The documentation is still pending.

@Angelmmiguel Angelmmiguel marked this pull request as ready for review November 14, 2022 15:42
Copy link
Contributor

@gzurl gzurl left a comment

Choose a reason for hiding this comment

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

LGTM!

@Angelmmiguel
Copy link
Contributor Author

Thanks for the review @gzurl ! I'm going to add the missing use case of allowing html files in the public folder.

Copy link
Contributor

@assambar assambar left a comment

Choose a reason for hiding this comment

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

Ship it!

You could add this later, but I think a simple example worker that uses static assets will help the adoption of this feature.
IDK, for example something simple that creates a business card with some background image based on a call to make-business-card.js?first_name=John&last_name=Doe&phone=123345...

@Angelmmiguel
Copy link
Contributor Author

@gzurl @assambar @ereslibre I completed the feature by adding support for static HTML files. Now, the /public/about.html file will be mounted in /about automatically.

You could add this later, but I think a simple example worker that uses static assets will help the adoption of this feature.
IDK, for example something simple that creates a business card with some background image based on a call to make-business-card.js?first_name=John&last_name=Doe&phone=123345...

This is an interesting use case. It can work for OpenGraph images and business cards (as you suggested). I will give a second though to that idea and will implement some examples around. However, those will work purely with workers, so I don't think static assets will be used that much in the example.

Copy link
Contributor

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

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

Looking fantastic; thanks @Angelmmiguel! LGTM. A minor optional comment.

src/main.rs Outdated Show resolved Hide resolved
@Angelmmiguel Angelmmiguel merged commit dea0581 into main Nov 15, 2022
@ereslibre ereslibre deleted the 7-support-static-assets branch November 18, 2022 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support static assests in handlers
5 participants