A PLC Mirror written in Rust

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

+30 -1
+1
Cargo.lock
··· 1406 "deadpool-postgres", 1407 "dropshot", 1408 "eyre", 1409 "ipld-core", 1410 "reqwest", 1411 "schemars",
··· 1406 "deadpool-postgres", 1407 "dropshot", 1408 "eyre", 1409 + "hyper", 1410 "ipld-core", 1411 "reqwest", 1412 "schemars",
+1
Cargo.toml
··· 7 chrono = { version = "0.4.39", features = ["serde"] } 8 deadpool-postgres = "0.14.1" 9 dropshot = "0.16.0" 10 eyre = "0.6.12" 11 ipld-core = { version = "0.4.1", features = ["serde"] } 12 reqwest = { version = "0.12.12", features = ["native-tls", "json"] }
··· 7 chrono = { version = "0.4.39", features = ["serde"] } 8 deadpool-postgres = "0.14.1" 9 dropshot = "0.16.0" 10 + hyper = "1.6.0" 11 eyre = "0.6.12" 12 ipld-core = { version = "0.4.1", features = ["serde"] } 13 reqwest = { version = "0.12.12", features = ["native-tls", "json"] }
+16 -1
src/api.rs
··· 1 use crate::types::{DidDocument, JsonCid, PlcEntry, PlcOperationType}; 2 use crate::{ApiContext, db}; 3 - use dropshot::{ClientErrorStatusCode, HttpError, HttpResponseOk, Path, RequestContext, endpoint}; 4 use ipld_core::cid::Cid; 5 use schemars::JsonSchema; 6 use serde::Deserialize; ··· 16 ClientErrorStatusCode::GONE, 17 format!("DID not available: {did}"), 18 ) 19 } 20 21 #[derive(Debug, JsonSchema, Deserialize)]
··· 1 use crate::types::{DidDocument, JsonCid, PlcEntry, PlcOperationType}; 2 use crate::{ApiContext, db}; 3 + use dropshot::{ 4 + Body, ClientErrorStatusCode, HttpError, HttpResponseOk, Path, RequestContext, endpoint, 5 + }; 6 + use hyper::Response; 7 use ipld_core::cid::Cid; 8 use schemars::JsonSchema; 9 use serde::Deserialize; ··· 19 ClientErrorStatusCode::GONE, 20 format!("DID not available: {did}"), 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")))?) 34 } 35 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 api_desc.register(api::get_plc_audit_log)?; 43 api_desc.register(api::get_last_op)?; 44 api_desc.register(api::resolve_did)?; 45 46 Ok(api_desc) 47 }
··· 42 api_desc.register(api::get_plc_audit_log)?; 43 api_desc.register(api::get_last_op)?; 44 api_desc.register(api::resolve_did)?; 45 + api_desc.register(api::index)?; 46 47 Ok(api_desc) 48 }