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:
parent
53679522fa
commit
cd2e03811e
9 changed files with 155 additions and 45 deletions
14
entryway/Cargo.toml
Normal file
14
entryway/Cargo.toml
Normal 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
33
entryway/src/main.rs
Normal 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")
|
||||
// }
|
||||
Loading…
Add table
Add a link
Reference in a new issue