README
¶
Todo Application
This is a simple Todo application built in Go that provides a REST API to manage tasks. The application supports creating, listing, marking tasks as complete, and deleting tasks. It also includes a feature flag to enable or disable certain endpoints.
Table of Contents
OpenAPI Specification
The OpenAPI specification for the application's REST API is provided in the openapi.yaml
file. This file describes the available endpoints, request and response structures, and their attributes. You can use tools like Swagger UI to visualize and interact with the API documentation. The OpenAPI spec file is located in the project root.
Building the Application
To build the application, ensure you have Go installed on your machine. Then follow these steps:
-
Open a terminal and navigate to the project root directory.
-
Run the following command to build the application:
go build -o todo-app .
This will generate an executable file named todo-app
in the current directory.
Running the Application
To run the application, follow these steps:
-
After building the application, run the following command:
./todo-app
-
The application will start and listen on port 9999 by default.
Testing the Application
To run tests for the application and view coverage, follow these steps:
-
Open a terminal and navigate to the project root directory.
-
Run the following command to run tests and generate coverage:
go test -coverprofile=coverage.out ./...
-
To view coverage in the terminal, run:
go tool cover -func=coverage.out
-
To generate an HTML coverage report, run:
go tool cover -html=coverage.out -o coverage.html
You can open the coverage.html
file in a web browser to view the coverage report.
Feature Flag
The application includes a feature flag that can be used to enable or disable certain endpoints. By default, the flag is disabled. To enable or disable the flag, you can use the /toggleflag
endpoint using a POST request.
Enabling the Feature Flag
To enable the feature flag, send a POST request to /toggleflag
endpoint:
curl -X POST http://localhost:9999/toggleflag
Disabling the Feature Flag
To disable the feature flag, send another POST request to the /toggleflag
endpoint:
curl -X POST http://localhost:9999/toggleflag
Dockerizing the Application
The application can also be containerized using Docker for easier deployment.
Building the Docker Image
To build a Docker image of the application, follow these steps:
-
Open a terminal and navigate to the project root directory.
-
Run the following command to build the Docker image:
docker build -t todoapp .
Running the Docker Container
To run the Docker container from the built image, follow these steps:
-
After building the Docker image, run the following command to start a container:
docker run -d --name todo-container -p 9999:9999 todoapp
-
The application will be accessible at
http://localhost:9999
.
Documentation
¶
There is no documentation for this package.