Add html index page that lists repo contents
This commit is contained in:
+8
-1
@@ -13,11 +13,13 @@ use tower_http::{compression::CompressionLayer, services::ServeDir, trace::Trace
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
mod flatpak;
|
||||
mod index;
|
||||
mod upload;
|
||||
mod util;
|
||||
|
||||
#[derive(Default)]
|
||||
struct SrvState {
|
||||
/// Absolute path to the flatpak ostree repository
|
||||
repo: Mutex<PathBuf>,
|
||||
api_key: String,
|
||||
gpg_key_id: String,
|
||||
@@ -59,7 +61,10 @@ async fn main() -> anyhow::Result<()> {
|
||||
// ostree init --repo=~/my-apps --mode=archive-z2
|
||||
|
||||
// Sanity check that opt.repo looks like a valid ostree dir
|
||||
let repo = opt.repo;
|
||||
let repo = opt
|
||||
.repo
|
||||
.canonicalize()
|
||||
.context("Failed to canonicalize repo dir")?;
|
||||
let repo_looks_valid =
|
||||
repo.is_dir() && repo.join("objects").is_dir() && repo.join("refs").is_dir();
|
||||
if !repo_looks_valid {
|
||||
@@ -76,6 +81,8 @@ async fn main() -> anyhow::Result<()> {
|
||||
let state: SharedState = Arc::new(state);
|
||||
|
||||
let app = Router::new()
|
||||
.route("/", get(index::index))
|
||||
.route("/index.html", get(index::index))
|
||||
.route("/flatpak-bundle/upload", post(upload::flatpak_bundle))
|
||||
// Explicitly deny access to internal OSTree directories.
|
||||
.route("/state/{*path}", get(|| ready(StatusCode::NOT_FOUND)))
|
||||
|
||||
Reference in New Issue
Block a user