FGtatsuro / api_server_poc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API Server PoC

検証環境

  • OSX(10.15.7)
  • Docker(Engine: 20.10.5)
  • GNU Make(3.81)

タスク

APIサーバのビルド

$ make build

APIサーバの起動

$ make start

APIサーバの停止

$ make stop

specテストの実行

$ make spec

APIサーバの仕様

  • 対応プロトコル: HTTP(HTTPSには対応していない)

(*)リクエストサンプルの実行には、以下のツールを使用する。

/api

  • GET: http://httpbin.org/headers へのGETアクセス結果を返す
$ curl -I -X GET '127.0.0.1:8080/api' -H 'authorization: tmp'
HTTP/1.1 200 OK
Content-Length: 219
Content-Type: text/plain; charset=utf-8
...
$ curl -s -X GET '127.0.0.1:8080/api' -H 'authorization: tmp' | jq '.'
{
  "headers": {
    "Accept-Encoding": "gzip",
    "Authorization": "tmp",
    "Host": "httpbin.org",
    "User-Agent": "Go-http-client/1.1",
    "X-Amzn-Trace-Id": "Root=1-60911f5e-30da301d0e95779a0cd4fa2a"
  }
}
  • authorization ヘッダがない場合、Status 401を返す
$ curl -I -X GET '127.0.0.1:8080/api'
HTTP/1.1 401 Unauthorized
Content-Type: text/plain; charset=utf-8
Content-Length: 25
...

About


Languages

Language:Go 62.2%Language:Makefile 22.4%Language:Dockerfile 10.9%Language:Python 4.5%