Skip to main content

codoseo_web/routes/
bot.rs

1//! `/bot`: what CodoSEObot is, so site owners can recognise, allow or block it. The crawler's
2//! user agent points here.
3
4use askama::Template;
5use axum::extract::State;
6use axum::response::{IntoResponse, Response};
7use codoseo_core::crawl::USER_AGENT;
8
9use super::quick::require_cloud;
10use crate::error::AppError;
11use crate::render::html;
12use crate::state::AppState;
13
14#[derive(Template)]
15#[template(path = "bot/index.html")]
16pub struct BotPage {
17    pub user_agent: &'static str,
18    pub ip: Option<String>,
19    pub base: String,
20}
21
22pub async fn page(State(state): State<AppState>) -> Result<Response, AppError> {
23    require_cloud(&state)?;
24    Ok(html(&BotPage {
25        user_agent: USER_AGENT,
26        ip: state.config.bot_ip.clone(),
27        base: state.config.origin(),
28    })?
29    .into_response())
30}