Toggle API is the web service responsible for managing feature toggles within XPTO. This service maintains toggle values state, so that applications that consume it can have their values change dynamically.
The Toggle API is split into the two main resources it manages.
The first one is the toggle resource. A toggle is comprised of a name, a default boolean value and a persistence identifier.
The next one is the application override. An application override is used when a toggle is required to have a different value than the default, but only for a specific application. It is comprised of an application reference, a toggle identifier and a value for the toggle.
You can also make use of this Postman collection to interact with the service.
GET api/toggle
Code: 200 OK
Content:
[
{
"id": 1,
"name": "myToggle",
"defaultValue": true
},
{
"id": 2,
"name": "otherToggle",
"defaultValue": false
}
]
GET api/toggle/{id}
Code: 200 OK
Content:
{
"id": 1,
"name": "myToggle",
"defaultValue": true
}
Code: 404 Not Found
POST api/toggle
Content:
{
"name": "feature",
"defaultValue": true
}
Code: 201 Created
Content:
{
"id": 1,
"name": "myToggle",
"defaultValue": true
}
PUT api/toggle/{id}
Content:
{
"id": 1,
"name": "feature",
"defaultValue": true
}
Code: 204 No Content
Code: 404 Not Found
Code: 400 Bad Request
(usually when id
differs from content and URL)
DELETE api/toggle/{id}
Code: 204 No Content
Code: 404 Not Found
GET api/application/{application}/toggle
Code: 200 OK
Content:
[
{
"toggleId": 1,
"toggleName": "feature1",
"value": true
},
{
"toggleId": 2,
"toggleName": "myToggle",
"value": true
}
]
GET api/application/{application}/toggle/{toggleId}
Code: 200 OK
Content:
{
"toggleId": 1,
"toggleName": "myToggle",
"value": true
}
Code: 404 Not Found
POST api/application/{application}/toggle
Content:
{
"toggleId": 1,
"toggleName": "myToggle",
"value": true
}
Code: 201 Created
Content:
{
"toggleId": 1,
"toggleName": "myToggle",
"value": true
}
PUT api/application/{application}/toggle/{toggleId}
Content:
{
"toggleId": 1,
"toggleName": "myToggle",
"value": true
}
Code: 204 No Content
Code: 404 Not Found
Code: 400 Bad Request
DELETE api/application/{application}/toggle/{toggleId}
Code: 204 No Content
Code: 404 Not Found
Toggle API is a .NET Core 2.0 application.
- Clone/fork the repository
- Build from source using
dotnet build
- Execute the tests using
dotnet test
- Run the application locally
dotnet run --project src/ToggleApi/ToggleApi.csproj
- Debug using your .NET IDE of choice
- Implement a basic authentication and authorisation mechanism, to ensure service users are recognised and have permissions to modify resources (for instance, using JSON Web Tokens).
- Implement a push mechanism, so that toggle state consumers (the applications) can evolve from the polling nature of the current status quo. This could be achieved by publishing an event to a messaging service of choice (example: RabbitMQ), which applications would then consume.