Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Task Manager API

A simple RESTful API for managing tasks, built with Go and the Gin web framework.

Features

  • List all tasks
  • Get a task by ID
  • Add a new task
  • Update a task
  • Delete a task

Task Model

Each task has the following fields:

  • id (string): Unique identifier
  • title (string): Task title
  • description (string): Task details
  • duedate (string, RFC3339): Due date/time
  • status (string): Task status (e.g., Pending, In Progress, Completed)

Getting Started

Prerequisites

  • Go 1.18 or later

Installation & Run

  1. Clone this repository or copy the code to your machine.
  2. Install dependencies:
    go mod tidy
  3. Run the server:
    go run main.go

The server will start at http://localhost:8080.

API Endpoints

List all tasks

  • GET /tasks
  • Response: JSON array of all tasks

Get a task by ID

  • GET /tasks/{id}
  • Response: JSON object of the task, or { "message": "task not found" } if not found

Add a new task

  • POST /tasks
  • Request Body:
    {
      "id": "4",
      "title": "New Task",
      "description": "Details",
      "duedate": "2025-07-15T15:04:05Z",
      "status": "Pending"
    }
  • Response: JSON object of the created task

Update a task

  • PUT /tasks/{id}
  • Request Body: (fields to update)
  • Response: Updated task object or error message

Delete a task

  • DELETE /tasks/{id}
  • Response: { "message": "task removed" } or error message

Example cURL Commands

List all tasks:

curl http://localhost:8080/tasks

Get a task by ID:

curl http://localhost:8080/tasks/1

Add a new task:

curl -X POST http://localhost:8080/tasks \
  -H "Content-Type: application/json" \
  -d '{"id":"4","title":"New Task","description":"Details","duedate":"2025-07-15T15:04:05Z","status":"Pending"}'

Update a task:

curl -X PUT http://localhost:8080/tasks/1 \
  -H "Content-Type: application/json" \
  -d '{"title":"Updated Task","description":"Updated details"}'

Delete a task:

curl -X DELETE http://localhost:8080/tasks/1

Project Structure

  • main.go — Main application file with all routes and handlers

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages