~vpzom/lotide

e971bcca4a7b2756f71ab505497cabb13ae9000e — Colin Reeder 11 months ago 072f4c1
Add api/unstable/instance endpoint
1 files changed, 21 insertions(+), 0 deletions(-)

M src/routes/api/mod.rs
M src/routes/api/mod.rs => src/routes/api/mod.rs +21 -0
@@ 129,6 129,10 @@ pub fn route_api() -> crate::RouteNode<()> {
            )
            .with_child("communities", communities::route_communities())
            .with_child(
                "instance",
                crate::RouteNode::new().with_handler_async("GET", route_unstable_instance_get),
            )
            .with_child(
                "posts",
                crate::RouteNode::new()
                    .with_handler_async("GET", route_unstable_posts_list)


@@ 461,6 465,23 @@ async fn route_unstable_nodeinfo_20_get(
        .body(body)?)
}

async fn route_unstable_instance_get(
    _: (),
    _ctx: Arc<crate::RouteContext>,
    _req: hyper::Request<hyper::Body>,
) -> Result<hyper::Response<hyper::Body>, crate::Error> {
    let body = serde_json::json!({
        "software": {
            "name": "lotide",
            "version": env!("CARGO_PKG_VERSION"),
        }
    });

    Ok(hyper::Response::builder()
        .header(hyper::header::CONTENT_TYPE, "application/json")
        .body(serde_json::to_vec(&body)?.into())?)
}

async fn route_unstable_posts_list(
    _: (),
    ctx: Arc<crate::RouteContext>,