Giter Club home page Giter Club logo

my-first-go-api's Introduction

Todo API with Go Fiber and Swagger

This is a simple RESTful API for managing todo items, implemented in Go using the Fiber web framework. It provides endpoints for creating, retrieving, updating, and deleting todo items. Swagger is used for API documentation.

Features

  • Create, Read, Update, Delete (CRUD) operations for todo items.
  • Swagger UI integration for API documentation and testing.
  • MongoDB for persistent storage.

Installation

Make sure you have Go installed on your system. Download Go

Clone the repository to your local machine:

git clone https://github.com/yourusername/your-repo-name.git
cd your-repo-name

Install the dependencies:

go mod tidy

Running the Application

To start the server, run:

go run main.go

Usage

The following endpoints are available:

  • POST /api/todo - Create a new todo item.
  • GET /api/todo - Retrieve all todo items.
  • GET /api/todo/{id} - Retrieve a todo item by its ID.
  • PUT /api/todo/{id} - Update a todo item by its ID.
  • DELETE /api/todo/{id} - Delete a todo item by its ID.
  • GET /api/todo/title/{title} - Retrieve todo items by title.

Swagger UI

To access the Swagger UI and interact with the API, visit:

http://localhost:8087/swagger/index.html

Create a Todo Item

This section describes how to create a new todo item using the POST method. Each todo item requires a title and content.

HTTP Request

  • Method: POST
  • Endpoint: /api/todo
  • Headers:
    • Content-Type: application/json

Request Body Provide the title and content for the todo item in the request body as JSON.

"title": "Sample Todo",
"content": "This is a sample todo item."

Successful Response A successful request returns the HTTP status code 201 Created and the created todo item, including its generated ID.

  • Status Code: 201 Created
  • Response Body:
"id": "5f6f4f4b50956f91ca8892",
"title": "Sample Todo",
"content": "This is a sample todo item."

my-first-go-api's People

Contributors

erenalp06 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.