Static web server in Rust (lib) #73
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a rework of PR #68
Static Web Server has published a library, so we can directly use the library now.
I've just copied their
main.rs
file. It works.Now we can publish a crate, but that crate is a generic static web server. What we want is a web server that contains the corresponding frontend app dist, don't we?
I think there are two ways of embedding the
dist
so the server version contains the corresponding frontend app dist:dist
dir in the cargo package (what I'm doing right now, but I do not know yet how to use the embedded files).dist
dir in the executable.Questions
This crate will be generic, meaning you have to provide the frontend app artefact to serve.
If we embed the
dist
folder into the binary, we have to find out how to serve it.I found this project https://github.com/pyrossh/rust-embed, but I'm not sure if that can work for us. I suppose we should write the files the first time the app is executed and then serve them from the disk. I don't think "Static Web Serve" allows you to serve directly from memory.
If we embed the
dist
folder in the package, we could try to use those files when the bin is installed withcargo install
because it builds the app. Maybe with a custom build script.With this version, we only fulfil goals 1 and 3 (see below), but not 2 (deployment), you need to combine both the server and the
dist
. If you install the app from sources, it's OK because you can build it, but you can not use directly the binary.Next
dist
(5MB) in the binary and use that distribution when you run it in production?Goals
From the previous PR.