Skip to content

gokayburuc/mini-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GO Mini REST API

simple and clean RESTful API built with Go using net/http and gorilla/mux.
This project demonstrates a minimal backend architecture with routing, middleware, and CRUD endpoints.

Project Goals

This project was created to demonstrate backend fundamentals in Go, including:

  • HTTP server setup
  • Routing and middleware
  • REST API principles
  • Clean code organization

Features

  • RESTful API design
  • Gorilla Mux router
  • In-memory data store
  • Logging middleware
  • Clean project structure

Project Structure

go-mini-rest-api/
├─ cmd/server/main.go
├─ internal/
│ ├─ handlers/
│ ├─ routes/
│ ├─ models/
│ └─ middleware/
├─ go.mod
└─ README.md

Prerequisites

You need to have Go 1.20 or newer version installed.

Libraries and Technologies Used

  • GO
  • net/http
  • gorilla/mux
  • curl

Run The Server

To Run The server:

go run cmd/server/main.go

Project run on localhost:8080 port. So you can check the given url below from any of your web browser:

http://localhost:8080

API End Points

Get all todos

GET /todos

Sample Response:

[
  {
    "id": 1,
    "title": "Learn Go",
    "completed": false
  }
]

Create a new todo

POST /todos

Sample request body:

{
  "title": "Build portfolio",
  "completed": false
}

Get todo by ID

GET /todos/{id}

Testing Commands

View All Tasks

To view the available TODO tasks in JSON format, run the following curl command in the terminal:

curl http://localhost:8080/todos

Add New Task

To add a new TODO task:

# Create todo
curl -X POST http://localhost:8080/todos \
 -H "Content-Type: application/json" \
 -d '{"title":"Build portfolio","completed":false}'

Get Todo By ID

Get a todo by ID:

# Get todo by id
curl http://localhost:8080/todos/1

TODO - Features to Add

  • Update / Delete Endpoints
  • Unit Testing
  • Docker file

About

GO Mini Rest API : Simple Todo App

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages