An opinionated wrapper around FastAPI with custom microservice registration
Project description
Picoapi
A wrapper around FastAPI to simplify microservice creation. Very opinionated but also simple to fork if you would like to add your own version of service registration and configuration to FastAPI.
Usage
create a .env file or export the following variables:
| ENV variable | Required (default) | Default | Description | Examples | Implemented |
|---|---|---|---|---|---|
| API_HOST | Yes | The host of the API | myhost|123.123.123.123|localhost|127.0.0.1 | ||
| API_PORT | No | 8888 | The port of the API | 8080 | |
| API_BIND | Yes | The interface descriptor to bind to | 127.0.0.1|0.0.0.0 | ||
| API_TITLE | Yes | The FastAPI title | Example API Name | ||
| API_DESCRIPTION | No | A brief Description | The FastAPI description | An Example of a short description about an API | |
| API_REGISTER_PATH | Yes | The url of the Keeper registration endpoint (similar to consul) | http://keeper:8100/register | ||
| API_HEALTH_PATH | No | The path relative to this FastAPI to call for health checks | /health | ||
| API_HEALTH_INTERVAL | No | 300 | The frequency to perform health checks (in seconds) | 300 | |
| API_VERSION | No | 0.0.1 | The version of this FastAPI | 0.0.1-alpha | |
| API_TAGS | No | The tags for this microservice, used as part of discovery, delimited with ":" (like $PATH) | servicetag1:servicetag2:servicetag3 | ||
| API_CORS_ALLOW_ORIGINS | No | * | The CORS allowed origins, delimited with "!" | No | |
| API_CORS_ALLOW_METHODS | No | * | The CORS allowed methods, delimited with "!" | No | |
| API_CORS_ALLOW_HEADERS | No | * | The CORS allowed headers, delimited with "!" | No |
Example .env file:
# API config
# ==========
API_BIND="0.0.0.0"
API_HOST="localhost"
API_PORT="8888"
API_TITLE="test"
API_DESCRIPTION="test description"
API_VERSION="0.0.1-alpha"
# microservice registration
# =========================
API_KEEPER_URL="http://localhost:8100/register"
API_HEALTH_PATH="/health"
API_HEALTH_INTERVAL="300"
Authors & Contributors
- Patrick Coffey - Author
- Asanga Abeyaratne - Contributor
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file picoapi-1.0.4.tar.gz.
File metadata
- Download URL: picoapi-1.0.4.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d75fb5ca872f28c6643c7ef514f2e6b5d8e4b39f28225082e39ae4730d871fb
|
|
| MD5 |
c9d894b624f390c3fdd148b6afbc8486
|
|
| BLAKE2b-256 |
1b4f9b188cb8c86576492d10fcebb9fb9fc495d4eaddba609549efd17dd33a15
|
File details
Details for the file picoapi-1.0.4-py3-none-any.whl.
File metadata
- Download URL: picoapi-1.0.4-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a5f2f18e57b6523283fddae1cf600cea6348b93fa63dd7a74734ba8ec16a049
|
|
| MD5 |
c1b4cbeb0b469553bead8718760209e3
|
|
| BLAKE2b-256 |
e3bb0457525bea8f5bba9b299de310121a805e6f3e4ab7c7b7fca26db0d00525
|