Skip to content

Saku0512/specter

Repository files navigation

specter

Ask DeepWiki CI Go Report Card OpenSSF Scorecard Go Version Latest Release VS Code Marketplace VS Code Installs Downloads License: MIT

English

specter は軽量なモック API サーバーです。エンドポイントを YAML で定義して、すぐに起動できます。

  • Hot reload: config.yml を編集すると変更がすぐ反映されます
  • Response templates、faker、stateful mocking、rate limiting に対応
  • 単一バイナリで動作し、追加のランタイム依存はありません

インストール

Docker

docker run -v $(pwd)/config.yml:/config.yml ghcr.io/saku0512/specter -c /config.yml

Homebrew (macOS / Linux)

brew tap Saku0512/specter https://github.com/Saku0512/specter
brew install specter

curl (macOS / Linux)

curl -fsSL https://raw.githubusercontent.com/Saku0512/specter/main/install.sh | bash

PowerShell (Windows)

irm https://raw.githubusercontent.com/Saku0512/specter/main/install.ps1 | iex

リリース検証

リリースには SHA256SUMS.txt と SPDX JSON SBOM が添付されます。install.shinstall.ps1 は、バイナリを配置する前に SHA256 を検証します。

手動で確認する場合:

VERSION=v1.0.1
ASSET=specter_linux_amd64
curl -LO "https://github.com/Saku0512/specter/releases/download/${VERSION}/${ASSET}"
curl -LO "https://github.com/Saku0512/specter/releases/download/${VERSION}/SHA256SUMS.txt"
grep "  ${ASSET}$" SHA256SUMS.txt | sha256sum --check -
gh attestation verify "${ASSET}" --repo Saku0512/specter

Quick start

specter init          # config.yml を生成
specter init --template crud  # CRUD スターターを生成
specter examples      # サンプル設定を一覧表示
specter doctor -c config.yml  # 設定・参照ファイル・ポートを診断
specter -c config.yml # サーバーを起動
routes:
  - path: /users
    method: GET
    response:
      - id: 1
        name: Alice

この設定で GET /users にアクセスすると、YAML に書いたレスポンスが返ります。

ドキュメント

動作する設定例は config.example.yml を見てください。

開発

通常のテストは make test で実行できます。Go fuzzing をローカルで回す場合は次を使います。

make fuzz
FUZZTIME=30s make fuzz

fuzz target は config YAML parser と request matcher をインメモリで検証するため、ネットワークアクセスは不要です。

ライセンス

MIT

About

golang mock api server

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors