mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-26 03:59:55 +00:00
Remove session and errors middleware from static route
Co-Authored-By: Antonio Scandurra <me@as-cii.com> Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
51a617dd5d
commit
6e8d35379c
2 changed files with 11 additions and 8 deletions
|
@ -1,18 +1,16 @@
|
||||||
use crate::{AppState, Request};
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use rust_embed::RustEmbed;
|
use rust_embed::RustEmbed;
|
||||||
use std::sync::Arc;
|
|
||||||
use tide::{http::mime, Server};
|
use tide::{http::mime, Server};
|
||||||
|
|
||||||
#[derive(RustEmbed)]
|
#[derive(RustEmbed)]
|
||||||
#[folder = "static"]
|
#[folder = "static"]
|
||||||
struct Static;
|
struct Static;
|
||||||
|
|
||||||
pub fn add_routes(app: &mut Server<Arc<AppState>>) {
|
pub fn add_routes(app: &mut Server<()>) {
|
||||||
app.at("/static/*path").get(get_static_asset);
|
app.at("/*path").get(get_static_asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_static_asset(request: Request) -> tide::Result {
|
async fn get_static_asset(request: tide::Request<()>) -> tide::Result {
|
||||||
let path = request.param("path").unwrap();
|
let path = request.param("path").unwrap();
|
||||||
let content = Static::get(path).ok_or_else(|| anyhow!("asset not found at {}", path))?;
|
let content = Static::get(path).ok_or_else(|| anyhow!("asset not found at {}", path))?;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
mod admin;
|
mod admin;
|
||||||
mod assets;
|
mod assets;
|
||||||
mod auth;
|
mod auth;
|
||||||
|
mod community;
|
||||||
mod db;
|
mod db;
|
||||||
mod env;
|
mod env;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod expiring;
|
mod expiring;
|
||||||
mod github;
|
mod github;
|
||||||
mod home;
|
mod home;
|
||||||
|
mod releases;
|
||||||
mod rpc;
|
mod rpc;
|
||||||
mod team;
|
mod team;
|
||||||
mod releases;
|
|
||||||
mod community;
|
|
||||||
|
|
||||||
use self::errors::TideResultExt as _;
|
use self::errors::TideResultExt as _;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
@ -179,11 +179,16 @@ pub async fn run_server(
|
||||||
community::add_routes(&mut web);
|
community::add_routes(&mut web);
|
||||||
admin::add_routes(&mut web);
|
admin::add_routes(&mut web);
|
||||||
auth::add_routes(&mut web);
|
auth::add_routes(&mut web);
|
||||||
assets::add_routes(&mut web);
|
|
||||||
|
let mut assets = tide::new();
|
||||||
|
assets.with(CompressMiddleware::new());
|
||||||
|
assets::add_routes(&mut assets);
|
||||||
|
|
||||||
let mut app = tide::with_state(state.clone());
|
let mut app = tide::with_state(state.clone());
|
||||||
rpc::add_routes(&mut app, &rpc);
|
rpc::add_routes(&mut app, &rpc);
|
||||||
|
|
||||||
app.at("/").nest(web);
|
app.at("/").nest(web);
|
||||||
|
app.at("/static").nest(assets);
|
||||||
|
|
||||||
app.listen(listener).await?;
|
app.listen(listener).await?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue