# traq-bot-http-rs [](https://github.com/H1rono/traq-bot-http-rs/actions/workflows/rust.yml) [](https://codecov.io/gh/H1rono/traq-bot-http-rs) [](https://github.com/H1rono/traq-bot-http-rs/actions/workflows/release.yml) [](https://docs.rs/traq-bot-http/latest/traq_bot_http/) [](https://github.com/H1rono/traq-bot-http-rs/blob/main/LICENSE) [](https://crates.io/crates/traq-bot-http) [](https://github.com/H1rono/traq-bot-http-rs/releases/latest) [](https://crates.io/crates/traq-bot-http) traQ BOTã®POSTリクエストをパースã™ã‚‹ãƒ©ã‚¤ãƒ–ラリã§ã™ã€‚ ## example `Cargo.toml` ```toml # ... [dependencies] http = "1" tower = "0.4" axum = "0.7" tokio = { version = "1", features = ["full"] } traq-bot-http = { version = "0.11", features = ["tower"] } ``` `main.rs` ```rust use std::{env, net::SocketAddr}; use axum::{routing::post_service, Router}; use http::StatusCode; use tokio::net::TcpListener; use tower::service_fn; use traq_bot_http::{payloads, RequestParser}; #[tokio::main] async fn main() { let verification_token = env::var("VERIFICATION_TOKEN").unwrap(); let parser = RequestParser::new(&verification_token); let handler = parser .into_handler() .on_message_created(service_fn(on_message_created)); let app = Router::new().route( "/", post_service(handler).handle_error(|_| async { StatusCode::INTERNAL_SERVER_ERROR }), ); let addr = SocketAddr::from(([127, 0, 0, 1], 8080)); let server = TcpListener::bind(addr).await.unwrap(); axum::serve(server, app).await.unwrap(); } async fn on_message_created( payload: payloads::MessageCreatedPayload, ) -> Result<(), std::convert::Infallible> { print!( "{}ã•ã‚“ãŒãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’投稿ã—ã¾ã—ãŸã€‚\n内容: {}\n", payload.message.user.display_name, payload.message.text ); Ok(()) } ``` ## Features feature | 機能 | ãƒãƒ¼ã‚¸ãƒ§ãƒ³ :-- | :-- | :-- `uuid` | ペイãƒãƒ¼ãƒ‰ã®UUID値ãŒ[`uuid::Uuid`](https://docs.rs/uuid/latest/uuid/struct.Uuid.html)åž‹ã« | [v0.4.0](https://github.com/H1rono/traq-bot-http-rs/releases/tag/v0.4.0)ã‹ã‚‰ `time` | ペイãƒãƒ¼ãƒ‰ã®ã‚¿ã‚¤ãƒ スタンプ値([RFC3339 format](https://tools.ietf.org/html/rfc3339#section-5.6))ãŒ[`time::OffsetDateTime`](https://docs.rs/time/latest/time/struct.OffsetDateTime.html)åž‹ã« | [v0.5.0](https://github.com/H1rono/traq-bot-http-rs/releases/tag/v0.5.0)ã‹ã‚‰ `chrono` | ペイãƒãƒ¼ãƒ‰ã®ã‚¿ã‚¤ãƒ スタンプ値ãŒ[`chrono::DateTime<chrono::Utc>`](https://docs.rs/chrono/latest/chrono/struct.DateTime.html)åž‹ã« | [v0.6.0](https://github.com/H1rono/traq-bot-http-rs/releases/tag/v0.6.0)ã‹ã‚‰ `http` | [`http::Request`](https://docs.rs/http/latest/http/request/struct.Request.html)åž‹ã®ã‚µãƒãƒ¼ãƒˆ | [v0.10.0](https://github.com/H1rono/traq-bot-http-rs/releases/tag/v0.10.0)ã‹ã‚‰ `tower` | [`Handler`](https://docs.rs/traq-bot-http/latest/traq_bot_http/struct.Handler.html)æ§‹é€ ä½“ | [v0.10.1](https://github.com/H1rono/traq-bot-http-rs/releases/tag/v0.10.1)ã‹ã‚‰ ※`time`よりも`chrono`ã®æ–¹ãŒå„ªå…ˆã•ã‚Œã¾ã™ ## Supported Rust Version ç¾è¡Œã® MSRV(Minimum Supported Rust Version) 㯠**1.76.0** ã§ã™ã€‚ å°†æ¥çš„ã«MSRVã¯å¤‰æ›´ã•ã‚Œã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ãŒã€minorãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®æ›´æ–°ã§å°Žå…¥ã•ã‚Œã¾ã™ã€‚ ## Contributing Issue, Pull Requestã¯å¤§æ“è¿Žã§ã™ã€‚ ## Blogs about this repository - [Rustã§ãƒ©ã‚¤ãƒ–ラリを作ã£ãŸ | æ±äº¬ç§‘å¦å¤§å¦ãƒ‡ã‚¸ã‚¿ãƒ«å‰µä½œåŒå¥½ä¼štraP](https://trap.jp/post/1819/) - [Rustã§ãƒ©ã‚¤ãƒ–ラリを作ã£ãŸ 続編 | æ±äº¬ç§‘å¦å¤§å¦ãƒ‡ã‚¸ã‚¿ãƒ«å‰µä½œåŒå¥½ä¼štraP](https://trap.jp/post/2438/)