Api, split into Api, Entryway, and Router

For a lil side project I need to make an Entryway, and I already have
enough infrastructure here that I don't want to redo anything.
This commit is contained in:
Julia Lange 2025-07-02 10:36:30 -07:00
parent 53679522fa
commit cd2e03811e
Signed by: Julia
SSH key fingerprint: SHA256:5DJcfxa5/fKCYn57dcabJa2vN2e6eT0pBerYi5SUbto
9 changed files with 155 additions and 45 deletions

14
entryway/Cargo.toml Normal file
View file

@ -0,0 +1,14 @@
[package]
name = "entryway"
version = "0.1.0"
edition = "2024"
[dependencies]
atproto.workspace = true
router.workspace = true
http = "1.3.1"
serde.workspace = true
serde_json.workspace = true
tokio.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true

33
entryway/src/main.rs Normal file
View file

@ -0,0 +1,33 @@
use router::{
Router,
Endpoint,
xrpc::{
QueryInput,
ProcedureInput,
Response,
error,
},
};
use atproto::types::Nsid;
use http::status::StatusCode;
#[tokio::main]
async fn main() {
let subscriber = tracing_subscriber::FmtSubscriber::new();
let _ = tracing::subscriber::set_global_default(subscriber);
let mut router = Router::new();
// let get_nsid = Nsid::new(String::from("me.woach.get")).expect("me.woach.get is a valid nsid");
// let post_nsid = Nsid::new(String::from("me.woach.post")).expect("me.woach.post is a valid nsid");
// router = router.add_endpoint(Endpoint::new_xrpc_query(get_nsid, test));
// router = router.add_endpoint(Endpoint::new_xrpc_procedure(post_nsid, test2));
router.serve().await;
}
// async fn test(_data: QueryInput) -> Response {
// error(StatusCode::OK, "error", "message")
// }
//
// async fn test2(_data: ProcedureInput) -> Response {
// error(StatusCode::OK, "error", "message")
// }