Router, add xrpc function interface, test in main
Adds an interface for adding xrpc queries and procedures that is a bit simpler than directly interfacing with axum. Should provide good scaffolding for next steps.
This commit is contained in:
parent
07f4720244
commit
d4a3a71e2f
5 changed files with 221 additions and 32 deletions
|
|
@ -1,9 +1,31 @@
|
|||
use crate::router::Router;
|
||||
use crate::router::{
|
||||
Router,
|
||||
Endpoint,
|
||||
xrpc::{
|
||||
QueryInput,
|
||||
ProcedureInput,
|
||||
Response,
|
||||
error,
|
||||
},
|
||||
};
|
||||
use axum::http::StatusCode;
|
||||
|
||||
|
||||
mod router;
|
||||
mod db;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let router = Router::new();
|
||||
let mut router = Router::new();
|
||||
router = router.add_endpoint(Endpoint::new_xrpc_query(String::from("me.woach.get"), test));
|
||||
router = router.add_endpoint(Endpoint::new_xrpc_procedure(String::from("me.woach.post"), 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