Skip to content

manjushsh/go-song-album

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Album CRUD API

This project is a simple CRUD (Create, Read, Update, Delete) API for managing albums, built using the Go programming language and the Gin web framework.

Tutorial from Go

TODO:

  • Implement CRUD API and connect to UI
  • Implement JWT Auth and middleware for protected routes
  • Setup CORS middleware
  • Implement UI and serve via Go Gin
  • Connect to DB
  • Dockerize the app
  • And more

Features

  • Create a new album
  • Retrieve a list of all albums
  • Retrieve a specific album by ID
  • Update an existing album
  • Delete a album

Prerequisites

  • Go 1.23.4 (Used for development) or higher
  • Gin web framework

Installation

  1. Clone the repository:

    git clone https://github.com/manjushsh/go-song-album.git
    cd go-song-album
  2. Install the dependencies:

    go mod tidy

Running the Application

To start the server, run:

go run main.go

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

API Endpoints

CRUD API Endpoints

Create a new album

  • Endpoint: POST /albums

  • Request Body:

    {
        "id": "1",
        "title": "Album Title",
        "artist": "Artist Name",
        "price": 9.99
    }
  • Response:

    {
        "id": "1",
        "title": "Album Title",
        "artist": "Artist Name",
        "price": 9.99
    }

Retrieve all albums

  • Endpoint: GET /albums

  • Response:

    [
        {
            "id": "1",
            "title": "Album Title",
            "artist": "Artist Name",
            "price": 9.99
        },
        {
            "id": "2",
            "title": "Another Album",
            "artist": "Another Artist",
            "price": 12.99
        }
    ]

Retrieve a specific album by ID

  • Endpoint: GET /albums/:id

  • Response:

    {
        "id": "1",
        "title": "Album Title",
        "artist": "Artist Name",
        "price": 9.99
    }

Update an existing album

  • Endpoint: PUT /albums/:id

  • Request Body:

    {
        "title": "Updated Album Title",
        "artist": "Updated Artist Name",
        "price": 10.99
    }
  • Response:

    {
        "id": "1",
        "title": "Updated Album Title",
        "artist": "Updated Artist Name",
        "price": 10.99
    }

Delete an album

  • Endpoint: DELETE /albums/:id

  • Response:

    {
        "message": "Album deleted successfully"
    }

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements