Skip to content

Commit

Permalink
Explicitly handle fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
c12i committed Sep 9, 2024
1 parent 68c3200 commit 3ec08ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/chc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use holochain::{
use parking_lot::RwLock;
use tokio::net::TcpListener;

use crate::routes::{add_records, get_record_data};
use crate::routes::{add_records, get_record_data, not_found};

#[derive(Debug)]
pub struct ChcService {
Expand Down Expand Up @@ -44,6 +44,7 @@ impl ChcService {
post(get_record_data),
)
.route("/add_records/:dna_hash/:agent_pubkey", post(add_records))
.fallback(not_found)
.with_state(Arc::new(AppState::default()));

ChcService { address, router }
Expand Down
7 changes: 5 additions & 2 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
mod add_records;
mod get_record_data;
mod not_found;

pub use add_records::add_records;
use anyhow::Context;
pub use get_record_data::{get_record_data, GetRecordDataResult};
use holochain::{
core::{AgentPubKeyB64, DnaHashB64},
prelude::CellId,
};

pub use add_records::add_records;
pub use get_record_data::{get_record_data, GetRecordDataResult};
pub use not_found::not_found;

#[derive(Debug, serde::Deserialize)]
#[allow(unused)]
pub struct ChcPathParams {
Expand Down
10 changes: 10 additions & 0 deletions src/routes/not_found.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use axum::{
body::Body,
http::{Request, StatusCode},
response::IntoResponse,
};

#[tracing::instrument]
pub async fn not_found(request: Request<Body>) -> impl IntoResponse {
(StatusCode::NOT_FOUND, "404 - Not Found")
}

0 comments on commit 3ec08ff

Please sign in to comment.