[[Rocket]]を使って[[REST API]]を作ってみる。
## Getting Started
https://rocket.rs/v0.4/guide/getting-started/
### Install
[[Rocket#前提条件]]を満たしたうえで`cargo.toml`に追加。
```toml
[dependencies]
rocket = "0.4.7"
```
### Macro有効化
`main.rs`に追加。
```rust
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
```
[[®proc_macro_hygiene]]と[[®decl_macro]]は[[Rust nightly]]のみで実装されたUnstableなMacro。
### 実装
READMEそのまんま。
```rust
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
pub fn main() {
rocket::ignite().mount("/", routes![index]).launch();
}
```
### 動作確認
`http://localhost:8000`にアクセスするとレスポンスが返却される
## MOC
- [[RocketでRequestを制御する]]
- [[RocketでResponseを制御する]]
- [[RocketでOpenAPI SpecificationからAPIドキュメントを作成]]