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

Serve files from embedded resources (rust-embed) #486

Closed
imclint21 opened this issue Mar 15, 2020 · 5 comments
Closed

Serve files from embedded resources (rust-embed) #486

imclint21 opened this issue Mar 15, 2020 · 5 comments

Comments

@imclint21
Copy link

Hi,

I'm looking for serve files that are store as embedded resources, the goal is to have a small WebUI compiled into the binary and serve it easily!

Do you have a good way to do that with warp? maybe you could propose this kind of feature.

Kind regards

@nytopop
Copy link

nytopop commented Mar 17, 2020

I was looking for something similar and couldn't find anything, so I wrote a macro to do it. You can find it here: static_dir.

@seanmonstar
Copy link
Owner

Could you clarify what you mean by embedded resources? Do you mean like things compiled in, like using include_str! or similar?

@imclint21
Copy link
Author

yeah exactly!

You know in C++ you can add files with resources.h i speak about the same things.

@seanmonstar
Copy link
Owner

If you have the resource available as a &'static str or &'static [u8], you can just use that in a reply, like this example:

let index = warp::path::end().map(|| warp::reply::html(INDEX_HTML));

@imclint21
Copy link
Author

Oh it's a good idea

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

No branches or pull requests

3 participants