https://github.com/ittokunvim/example-actix-web
Actix-web and Seaorm API
https://github.com/ittokunvim/example-actix-web
actix-web seaorm
Last synced: about 1 month ago
JSON representation
Actix-web and Seaorm API
- Host: GitHub
- URL: https://github.com/ittokunvim/example-actix-web
- Owner: ittokunvim
- Created: 2022-09-17T21:40:03.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-11T15:04:05.000Z (almost 3 years ago)
- Last Synced: 2025-01-12T00:32:52.633Z (over 1 year ago)
- Topics: actix-web, seaorm
- Language: Rust
- Homepage:
- Size: 223 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# example-rust-api
このリポジトリには、Rust言語の`actix-web`と`seaorm`を組み合わせたAPIサーバーを構成するためのソースコードがあります。
以下のコマンドを実行することで、動作を確認することができます。
試してみましょう!
### 動作要件
ここにあるソースコードを実行するためには`Docker`が必要になります。
インストールしておきましょう。
### 動かす
APIの立ち上げ
```bash
make run
```
APIの終了
```bash
make down
```
データベースにアクセス
```bash
make db-access
```
APIにアクセス
```bash
make api-bash
```
APIのテストを実行
```bash
make api-test
```
### 操作する
ルートにアクセス
```bash
curl http://0.0.0.0:8080
```
記事を投稿する
```bash
curl http://0.0.0.0:8080/posts -X POST -H 'Content-Type: application/json' -d '{"title": "bar", "text": "bar"}'
```
記事を閲覧する
```bash
curl http://0.0.0.0:8080/posts/1
```
記事を編集する
```bash
curl http://0.0.0.0:8080/posts/1 -X PATCH -H 'Content-Type: application/json' -d '{"title": "bar", "text": "bar"}'
```
記事のリストを見る
```bash
curl http://0.0.0.0:8080/posts
```
記事を削除する
```bash
curl http://0.0.0.0:8080/posts/1 -X DELETE
```