Files
tauri/templates/rust/src/server.rs
nothingismagick 13734c338b chore(merge) dev to master (#4)
* feat(readme) clarifications and styling
* fix(readme) logo position
* feat(scaffolding) folders, templates, rust, c, node WOW
* feat(proton) initial packages for webview and binding-rust
* feat(proton) new folder structure
* chore(compliance) readmes and licenses
* chore(npm) create package.json
* chore(proton) rename packages and create lib/rust
* chore(proton) create templates directory
* feat(rust) rustfmt tab_spaces = 2
* feat(rust) run fmt and fix template structure
* chore(npm) update package
- package name (@quasar/proton)
- node 10, npm 6.6, yarn 1.17.3 (security)
- .gitignore
- .npmignore
- add docs and spec dirs

Signed-off-by: Daniel Thompson-Yvetot <denjell@quasar.dev>
2019-07-14 14:50:49 +02:00

27 lines
844 B
Rust

use tiny_http::{Header, Response};
include!(concat!(env!("OUT_DIR"), "/data.rs"));
pub fn asset_response(path: &str) -> Response<std::io::Cursor<Vec<u8>>> {
let asset = ASSETS
.get(&format!("./target/compiled-web{}", path))
.unwrap()
.into_owned();
let mut response = Response::from_data(asset);
let header;
if path.ends_with(".svg") {
header = Header::from_bytes(&b"Content-Type"[..], &b"image/svg+xml"[..]).unwrap();
} else if path.ends_with(".css") {
header = Header::from_bytes(&b"Content-Type"[..], &b"text/css"[..]).unwrap();
} else if path.ends_with(".html") {
header = Header::from_bytes(&b"Content-Type"[..], &b"text/html"[..]).unwrap();
} else {
header = Header::from_bytes(&b"Content-Type"[..], &b"appication/octet-stream"[..]).unwrap();
}
response.add_header(header);
response
}