TheCoreMan / problematic-api-server

A server that has examples for every problematic API consumption issue one may face.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

problematic-api-server

I got 429 problems but an API ain't one.

cover

A server that has examples for every problematic API consumption issue one may face when consuming APIs.

This project is mostly for educational purposes, but it can be used as a reference for how to handle different API issues.

Usage

go run cmd/server.go

Configuration

The server can be configured using environment variables, with the PROBLEMATIC prefix:

  • PROBLEMATIC_HOST: The host to listen on. Defaults to 0.0.0.0.
  • PROBLEMATIC_PORT: The port to listen on. Defaults to 4578.
  • PROBLEMATIC_LOG_LEVEL: The log level to use. Defaults to debug. Use one of the following: panic, fatal, error, warn, info, debug, trace.
  • PROBLEMATIC_LOG_FORMAT: The log format to use. Defaults to text.
    • Use text for human-readable logs.
    • Use json for machine-readable logs. Useful when running in a deployed context.

For example, to change the port, run:

PROBLEMATIC_PORT=2345 go run cmd/server.go

To see all available configuration options, please review cmd/config.go.

Development

Pre-commit

This project uses pre-commit to run some checks before committing. To install it, run:

brew install pre-commit
pre-commit install

API

This project is based mostly around the API spec in spec/openapi.yaml. Use ./scripts/generate.sh to generate the server and client if you change the API.

Note: some files are ignored when generating the server and client. Make sure that your changes propagate to the ignored files as well.

To implement a specific service, go to /server/go/XXX_service.go and implement the methods there.

About

A server that has examples for every problematic API consumption issue one may face.

License:Mozilla Public License 2.0


Languages

Language:Go 89.3%Language:HTML 5.3%Language:Shell 3.5%Language:CSS 1.2%Language:JavaScript 0.7%