traQ BOTのPOSTリクエストをパースするライブラリです。
Cargo.toml
```toml
[dependencies] axum = "0.6" tokio = { version = "1.0", features = ["full"] } traq-bot-http = "0.6" ```
main.rs
```rust use std::{env, net::SocketAddr};
use axum::{ body::Bytes, extract::State, http::{HeaderMap, StatusCode}, routing::post, Router, };
use traqbothttp::{Event, RequestParser};
async fn main() { let verificationtoken = env::var("VERIFICATIONTOKEN").unwrap(); let parser = RequestParser::new(&verificationtoken); let app = Router::new().route("/", post(handler)).withstate(parser); let addr = SocketAddr::from(([127, 0, 0, 1], 8080)); axum::Server::bind(&addr) .serve(app.intomakeservice()) .await .unwrap(); }
async fn handler(
State(parser): State
feature | 機能 | バージョン
:-- | :-- | :--
uuid
| ペイロードのUUID値がuuid::Uuid
型に | v0.4.0から
time
| ペイロードのタイムスタンプ値(RFC3339 format)がtime::OffsetDateTime
型に | v0.5.0から
chrono
| ペイロードのタイムスタンプ値がchrono::DateTime<chrono::Utc>
型に | v0.6.0から
※time
よりもchrono
の方が優先されます
Issue, Pull Requestは大歓迎です。