Go JSON Task Manager API
This is a simple Task Manager API written in Go. The API provides basic CRUD (Create, Read, Update, Delete) functionality to manage tasks. Tasks are saved in a tasks.json file for persistence.
Table of Contents
Getting Started
Installation
- Clone the Repository:
git clone https://github.com/scottgriv/go-json_task_manager_api
- Change to the Directory:
cd go-json-task-manager-api
- Run the Server:
go run .
- The server should now be running on http://localhost:8080.
Usage
GET /tasks: Retrieve a list of all Tasks.
Response:
[
{ "id": 1, "name": "Sample Task" },
{ "id": 2, "name": "Modified Task" }
]
POST /task/create: Create a new Task.
Body:
{
"name": "Your Task Name"
}
DELETE /task/delete: Delete a Task by its ID.
Body:
{
"id": 1
}
PUT /task/update: Update an existing Task by its ID or create a new one if it doesn't exist.
Body:
{
"id": 1,
"name": "Updated Task Name"
}
PATCH /task/modify: Update specific fields of an existing Task by its ID.
Body:
{
"id": 1,
"name": "Modified Task Name"
}
Testing
Use a tool like Postman or curl to send requests to the server and test each endpoint. You can also import the included Postman collection in the api directory to get started.
What's Inside?
go-json_task_manager_api/ # Root directory
├── main.go # Entry point
├── router.go # Routes
├── handlers.go # Request handlers
├── tasks.go # Task model
├── postman/ # Postman collection
│ └── go-json_task_manager_api.postman_collection.json # Import this file into Postman
├── sample/ # Sample data
│ └── tasks_sample_output.json # Sample output from GET /tasks
├── tasks.json # Tasks data file
├── .gitignore # git ignore file
├── LICENSE # License file
└── README.md # This file
Resources
License
This project is released under the terms of The Unlicense, which allows you to use, modify, and distribute the code as you see fit.
- The Unlicense removes traditional copyright restrictions, giving you the freedom to use the code in any way you choose.
- For more details, see the LICENSE file in this repository.
Credits
Author: Scott Grivner
Email: scott.grivner@gmail.com
Website: scottgrivner.dev
Reference: Main Branch