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.1
Copyright
Rollpie, Irohabook
Publisher
math
Published
2026-09-14
Size
67.6 KB
Downloads
2
Checksum
1394ade0d23f53c562acdce1e27a9c4c559f73c22d104e84c7c03c6b2fcc47b0
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
//! 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, session};
//! use std::net::SocketAddr;
//! use std::sync::Arc;
//!
//! # async fn run() -> anyhow::Result<()> {
//! let conf = Conf::default();
//! let database = database::connect(&conf.database_url).await?;
//! let store = session::store(&conf, &database);
//! session::prepare(&store).await?;
//!
//! // 名前も置くかどうかも、ここで決める
//! 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: Arc::new(conf),
//! };
//! // ConnectInfo を入れると、CLIENT_IP_HEADER がないときに TCP の相手を使える
//! let app = route::wrap(routes, state).into_make_service_with_connect_info::<SocketAddr>();
//! # 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 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;