A PLC Mirror written in Rust

feat: neat 'lil index page, with the atproto standard (seemingly) ascii art.

+30 -1
+1
Cargo.lock
··· 1406 1406 "deadpool-postgres", 1407 1407 "dropshot", 1408 1408 "eyre", 1409 + "hyper", 1409 1410 "ipld-core", 1410 1411 "reqwest", 1411 1412 "schemars",
+1
Cargo.toml
··· 7 7 chrono = { version = "0.4.39", features = ["serde"] } 8 8 deadpool-postgres = "0.14.1" 9 9 dropshot = "0.16.0" 10 + hyper = "1.6.0" 10 11 eyre = "0.6.12" 11 12 ipld-core = { version = "0.4.1", features = ["serde"] } 12 13 reqwest = { version = "0.12.12", features = ["native-tls", "json"] }
+16 -1
src/api.rs
··· 1 1 use crate::types::{DidDocument, JsonCid, PlcEntry, PlcOperationType}; 2 2 use crate::{ApiContext, db}; 3 - use dropshot::{ClientErrorStatusCode, HttpError, HttpResponseOk, Path, RequestContext, endpoint}; 3 + use dropshot::{ 4 + Body, ClientErrorStatusCode, HttpError, HttpResponseOk, Path, RequestContext, endpoint, 5 + }; 6 + use hyper::Response; 4 7 use ipld_core::cid::Cid; 5 8 use schemars::JsonSchema; 6 9 use serde::Deserialize; ··· 16 19 ClientErrorStatusCode::GONE, 17 20 format!("DID not available: {did}"), 18 21 ) 22 + } 23 + 24 + #[endpoint{ 25 + method = GET, 26 + path = "/", 27 + }] 28 + // strictly this isn't the correct type, but it works 29 + pub async fn index(_rqctx: RequestContext<ApiContext>) -> Result<Response<Body>, HttpError> { 30 + Ok(Response::builder() 31 + .status(200) 32 + .header("Content-Type", "text/plain") 33 + .body(Body::with_content(include_str!("./index.txt")))?) 19 34 } 20 35 21 36 #[derive(Debug, JsonSchema, Deserialize)]
+11
src/index.txt
··· 1 + ____ _ _ ____ _ ____ 2 + | _ \ __ _ _ __ __ _| | _____ ___| |_ | _ \| | / ___| 3 + | |_) / _` | '__/ _` | |/ / _ \/ _ \ __| | |_) | | | | 4 + | __/ (_| | | | (_| | < __/ __/ |_ | __/| |__| |___ 5 + |_| \__,_|_| \__,_|_|\_\___|\___|\__| |_| |_____\____| 6 + 7 + A little Rust did:plc mirror for Parakeet. 8 + Use /{did} to resolve a DID. 9 + 10 + - https://gitlab.com/parakeet-social/plc-mirror 11 + - https://web.plc.directory
+1
src/lib.rs
··· 42 42 api_desc.register(api::get_plc_audit_log)?; 43 43 api_desc.register(api::get_last_op)?; 44 44 api_desc.register(api::resolve_did)?; 45 + api_desc.register(api::index)?; 45 46 46 47 Ok(api_desc) 47 48 }