fedimovies/src/mastodon_api/instance/views.rs

24 lines
613 B
Rust
Raw Normal View History

2021-11-07 08:52:57 +00:00
use actix_web::{get, web, HttpResponse, Scope};
2021-04-09 00:22:17 +00:00
use crate::config::Config;
use crate::errors::HttpError;
use crate::ethereum::contracts::ContractSet;
use super::types::InstanceInfo;
2021-04-09 00:22:17 +00:00
2021-11-07 08:52:57 +00:00
#[get("")]
async fn instance_view(
config: web::Data<Config>,
maybe_blockchain: web::Data<Option<ContractSet>>,
2021-04-09 00:22:17 +00:00
) -> Result<HttpResponse, HttpError> {
let instance = InstanceInfo::create(
config.as_ref(),
maybe_blockchain.as_ref().as_ref(),
);
2021-04-09 00:22:17 +00:00
Ok(HttpResponse::Ok().json(instance))
}
2021-11-07 08:52:57 +00:00
pub fn instance_api_scope() -> Scope {
web::scope("/api/v1/instance")
.service(instance_view)
}