Skip to content

YotaroSeki/HTTPServer

Repository files navigation

todo API server

set up

  1. Install Crystal lang
apt install crystal
  1. Install Amber framework
apt install amber
  1. Install postgresql
apt install postgres@11
  1. Edit config/environments/development.yml
database_url: postgres://#{YOUR_USER_NAME}:@localhost:5432/todo_development
  1. Create Table and migrate
amber db create migrate
  1. Run server
amber w

動作

  • 最初にlocalhost:3000にアクセスしてユーザー登録およびログインをする必要があります。
# イベント登録 API request
POST /api/v1/event
{"deadline": "2019-06-11T14:00:00+09:00", "title": "レポート提出", "memo": ""}

# イベント登録 API response
200 OK
{"status": "success", "message": "registered", "id": 1}

400 Bad Request
{"status": "failure", "message": "invalid date format"}
# イベント全取得 API request
GET /api/v1/event

# イベント全取得 API response
200 OK
{"events": [
    {"id": 1, "deadline": "2019-06-11T14:00:00+09:00", "title": "レポート提出", "memo": ""},
    ...
]}
# イベント1件取得 API request
GET /api/v1/event/${id}

# イベント1件取得 API response
200 OK
{"id": 1, "deadline": "2019-06-11T14:00:00+09:00", "title": "レポート提出", "memo": ""}

404 Not Found
# イベント1件削除 API request
DELETE /api/v1/event/${id}

# イベント1件取得 API response
204 OK

404 Not Found

About

HTTP server with amber

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published