Serve the CSS file
This commit is contained in:
parent
ef057eca66
commit
3f1316b3dd
|
@ -9,6 +9,8 @@ use warp::{filters::multipart::FormData, http::Response, multipart::Part};
|
||||||
|
|
||||||
use crate::{pages, App, AuthToken, FileId, FileInfo, ReadFileError, SessionToken};
|
use crate::{pages, App, AuthToken, FileId, FileInfo, ReadFileError, SessionToken};
|
||||||
|
|
||||||
|
const CSS: &str = include_str!("../templates/style.css");
|
||||||
|
|
||||||
pub async fn handle_index(
|
pub async fn handle_index(
|
||||||
app: App,
|
app: App,
|
||||||
token: Option<SessionToken>,
|
token: Option<SessionToken>,
|
||||||
|
@ -22,6 +24,13 @@ pub async fn handle_index(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn handle_css() -> Result<Response<String>, Error> {
|
||||||
|
Response::builder()
|
||||||
|
.header("content-type", "text/css")
|
||||||
|
.status(StatusCode::OK)
|
||||||
|
.body(CSS.to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn render_auth_page(message: Option<String>) -> Result<Response<String>, Error> {
|
pub fn render_auth_page(message: Option<String>) -> Result<Response<String>, Error> {
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.status(StatusCode::OK)
|
.status(StatusCode::OK)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
use cookie::Cookie;
|
use cookie::Cookie;
|
||||||
use handlers::{file, handle_auth, handle_upload, thumbnail};
|
use handlers::{file, handle_auth, handle_css, handle_upload, thumbnail};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
|
@ -119,6 +119,8 @@ pub async fn main() {
|
||||||
.and(maybe_with_session())
|
.and(maybe_with_session())
|
||||||
.then(handle_index);
|
.then(handle_index);
|
||||||
|
|
||||||
|
let styles = warp::path!("css").and(warp::get()).then(handle_css);
|
||||||
|
|
||||||
let auth = warp::path!("auth")
|
let auth = warp::path!("auth")
|
||||||
.and(warp::post())
|
.and(warp::post())
|
||||||
.and(with_app(app.clone()))
|
.and(with_app(app.clone()))
|
||||||
|
@ -145,7 +147,8 @@ pub async fn main() {
|
||||||
.then(move |id, old_etags, app: App| file(app, id, old_etags));
|
.then(move |id, old_etags, app: App| file(app, id, old_etags));
|
||||||
|
|
||||||
let server = warp::serve(
|
let server = warp::serve(
|
||||||
root.or(auth)
|
root.or(styles)
|
||||||
|
.or(auth)
|
||||||
.or(upload_via_form)
|
.or(upload_via_form)
|
||||||
.or(thumbnail)
|
.or(thumbnail)
|
||||||
.or(file)
|
.or(file)
|
||||||
|
|
Loading…
Reference in New Issue