Skip to content

Latest commit

 

History

History
315 lines (205 loc) · 5.43 KB

README.md

File metadata and controls

315 lines (205 loc) · 5.43 KB

Feature Flagger API

Simple Boolean Based Feature Flag API

Feature Flagger API is a a bare bones feature flag api that currently only supports boolean based features.

Features

  • List, Get, Create, Update, Delete features by name
  • Fast Redis database to store your features

Installation

feature-flagger-api requires Go v1.17+ to run.

Create an appropriate .env with these arguments, then start the server. Currently supports hot-reloading

# Values here are for a defualt local dev run
REDIS_DB_HOST="redis"
REDIS_DB_PORT="6379"
REDIS_DB_ID="0"
REDIS_DB_PASSWORD=""
SERVER_PORT=8080
git clone https://github.com/charliemenke/feature-flagger-api.git
cd feature-flagger-api
docker-compose up --build

API Endpoints


List Features

allows caller to see all features in database.

URL : /api/features

Method : GET

Success Responses

Condition : Server is up and running properly.

Code : 200 OK

[
    {
        "name": "feature1",
        "enabled": true
    },
    {
        "name": "feature2",
        "enabled": false
    }
]

Error Response

Condition : Server is not connected to Redis Databse properly or bad data is in Redis.

Code : 500 Internal Server Error

Content example :

Error getting features || Error preparing features to be returned

Create Feature

allows caller to create new feature in database.

URL : /api/features

Method : POST

Data constraints

{
    "name": string *required*,
    "enabled": boolean *optional*
}

enabled is a optional field, if not supplied the feature will be defaulted to not being enabled

Success Responses

Condition : featureName is supplied and is unique in the database.

Code : 200 OK

Succesfully created feature <featureName>

Error Response

Condition : Bad data is sent in the body.

Code : 400 Bad Request

Content example :

Error reading request.

Condition : No name is supplied in the body.

Code : 400 Bad Request

Content example :

You must specify feature name.

Condition : Failure checking database for unique value.

Code : 500 Internal Server Error

Content example :

Error checking if feature already exists.

Condition : Feature with featureName already exists in database.

Code : 409 Conflict

Content example :

This feature already exists, please update or delete it instead.

Condition : Failed to create new feature in database.

Code : 500 Internal Server Error

Content example :

Error adding feature: <error> .

Get Feature

allows caller to get a feature in database.

URL : /api/features/{featureName}

Method : GET

Success Responses

Condition : featureName exists in the database.

Code : 200 OK

{
    "name": "feature1",
    "enabled": true
}

Error Response

Condition : featureName does not exist in the database.

Code : 404 Not Found

Content example :

Feature: '<featureName>' does not exist in the database. Please check the feature name and try again.

Condition : Failed to check database for feature.

Code : 500 Internal Server Error

Content example :

Error getting feature: <error>.

Condition : Feature to return is malformed.

Code : 500 Internal Server Error

Content example :

Error preparing feature to be returned: <error>.

Update Feature

allows caller to update enabled status for a feature in database.

URL : /api/features/{featureName}

Method : PUT

Data constraints

{
    "enabled": boolean *required*
}

Success Responses

Condition : featureName exists and was successfully updated.

Code : 200 OK

Succesfully updated feature: <featureName>

Error Response

Condition : Bad data is sent in the body.

Code : 400 Bad Request

Content example :

Error reading request <error>.

Condition : No enabled status is supplied in the body.

Code : 400 Bad Request

Content example :

Request must supply 'enabled' field.

Condition : featureName does not exist in the database.

Code : 404 Not Found

Content example :

Feature: '<featureName>' does not exist in the database. Please check the feature name and try again.

Condition : Failed to check database for feature.

Code : 500 Internal Server Error

Content example :

Error getting feature: <error>.

Condition : Failure to update feature in database.

Code : 500 Internal Server Error

Content example :

Error updating feature: <error>.

Delete Feature

allows caller to delete feature in database.

URL : /api/features/{featureName}

Method : DELETE

Success Responses

Condition : featureName exists and was successfully updated.

Code : 200 OK

Succesfully deleted key: <featureName>

Error Response

Condition : Failure to delete feature in database.

Code : 500 Internal Server Error

Content example :

Error deleting feature: <error>.

Condition : No feature with featureName to delete in database.

Code : 404 Bad Request

Content example :

Could not find feature to delete: <featureName>.