Skip to content

f-llewellyn/comment-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Comment Store

This is a very basic rest API written in go as a learning exercise.

Getting Started

Before getting started, ensure you have golang and docker installed on your machine.

To start the server, run the following in the project root directory:

docker compose up
go mod download
go run main.go

If you have go installed on your machine, just run air in the root project directory.

Endpoints

All endpoints are codumented in a bruno collection whcih can be found in the api-docs directory.

GET /comment

Fetches all comments

// Example response
[
  {
    "Id": 2,
    "Username": "otherUzr",
    "Timestamp": "2024-10-11T16:28:52.85517+01:00",
    "Content": "This is another comment"
  },
  {
    "Id": 3,
    "Username": "Finn 2",
    "Timestamp": "2024-10-17T22:51:32+01:00",
    "Content": "Hello World!"
  },
  {
    "Id": 4,
    "Username": "Finn 4",
    "Timestamp": "2024-10-17T22:52:04+01:00",
    "Content": "Hello World!"
  },
]

GET /comment/{id}

Fetches comment with specified id

// Example response
{
  "Id": 2,
  "Username": "otherUzr",
  "Timestamp": "2024-10-11T16:28:52.85517+01:00",
  "Content": "This is another comment"
}

POST /comment

Creates comment with specified data

// Example request
{
  "Username": "User 1",
  "Content": "This is an example comment"
}

// Example response
{
  "Id": 32,
}

PUT /comment/{id}

Updates comment with specified id

// Example request
{
  "Content": "This is an updated comment"
}

// Example response
{
  "Id": 32,
  "Username: "Finn",
  "Content": "This is an updated comment",
  "Timestamp": "2024-10-20T14:30:54+01:00"
}

DELETE /comment/{id}

Deletes comment with specified id

About

A basic rest api created as a learning exercise

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published