diff options
Diffstat (limited to 'kittybox-rs/src/micropub')
-rw-r--r-- | kittybox-rs/src/micropub/mod.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/kittybox-rs/src/micropub/mod.rs b/kittybox-rs/src/micropub/mod.rs index 3328597..d0aeae0 100644 --- a/kittybox-rs/src/micropub/mod.rs +++ b/kittybox-rs/src/micropub/mod.rs @@ -596,6 +596,19 @@ pub async fn query<D: Storage>( } } +pub fn router<S: Storage + 'static>(storage: S, http: reqwest::Client) -> axum::routing::MethodRouter { + axum::routing::get(query::<S>) + .post(post::<S>) + .layer(tower_http::cors::CorsLayer::new() + .allow_methods([ + axum::http::Method::GET, + axum::http::Method::POST, + ]) + .allow_origin(tower_http::cors::Any)) + .layer(axum::Extension(storage)) + .layer(axum::Extension(http)) +} + #[cfg(test)] #[allow(dead_code)] impl MicropubQuery { |