Registry / RepositoryTypeScriptRustPython
Rollpie
ReadmeFiles
Versions
Info
Download
0.1.280.1 KB2026-09-140.1.167.6 KB2026-09-140.1.064.9 KB2026-09-14
Version
0.1.2
Copyright
Rollpie, Irohabook
Publisher
math
Published
2026-09-14
Size
80.1 KB
Downloads
1
Checksum
65387e928cd11d6abf76cfb0f7a839dd3b2b7bb9cdbe78e7b058d3213d9fbcc2
Dependencies
None

lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! mon — axum の上に、サーバーの土台を敷くライブラリ
//!
//! JSON で返す共通のエラー、失敗も JSON になる extractor、HTML の組み立て、
//! 別サーバへの中継、セッション(置き場は 4 通りから選ぶ)をまとめて持つ。
//!
//! **mon はパスを 1 つも取らない。** どのパスに何を置くかは使う側が決める。
//! [`route::wrap`] はミドルウェアを掛けて状態を入れるだけで、ルートは置かない。
//!
//! ```no_run
//! use axum::Router;
//! use axum::routing::get;
//! use mon::{AppState, Conf, database, page, relay, route, server, session};
//! use std::sync::Arc;
//! use tokio::net::TcpListener;
//!
//! # async fn run() -> anyhow::Result<()> {
//! let conf = Arc::new(Conf::default());
//! let database = database::connect(&conf.database_url).await?;
//! let store = session::store(&conf, &database);
//! session::prepare(&store).await?;
//! session::start_sweep(store.clone(), conf.session_max_age);
//!
//! // 名前も置くかどうかも、ここで決める
//! let routes = Router::new()
//!     .route("/health", get(route::health))
//!     .nest("/api/session", session::router())
//!     .nest("/relay", relay::router())
//!     .nest_service("/static", route::assets(&conf))
//!     .fallback(page::not_found);
//!
//! let state = AppState {
//!     database,
//!     client: relay::client(&conf)?,
//!     session: store,
//!     conf: conf.clone(),
//! };
//!
//! // ヘッダの受け取りに REQUEST_TIMEOUT の上限を掛け、TCP の相手を ClientIp に渡す
//! let listener = TcpListener::bind((conf.host, conf.port)).await?;
//! server::run(listener, route::wrap(routes, state), &conf, std::future::pending()).await?;
//! # Ok(())
//! # }
//! ```
//!
//! 設定は [`Conf`] を直接組み立てても、[`conf::load`] で環境変数から読んでもよい。

#![warn(missing_docs)]

pub mod conf;
pub mod database;
pub mod error;
pub mod extract;
pub mod html;
pub mod ip;
pub mod log;
pub mod page;
pub mod relay;
pub mod route;
pub mod server;
pub mod session;
pub mod state;

pub use conf::Conf;
pub use error::AppError;
pub use ip::ClientIp;
pub use session::{Session, SessionData, Store};
pub use state::AppState;