Skip to content

Ashwin-Rajeev/golang-simple-api-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang simple API server

A simple Dockerised API server using Golang and PostgreSQL.

Project Structure

    - internal
            |
            /app
                /api_helper.go
                /api.go
                /dal.go
                /models.go
                /repo.go
                /router.go
                /server.go
    - migration
            |
            /initial_migration.sql
    - docker-compose.yml
    - go.mod
    - go.sum
    - main.go

Dependencies

docker-compose == 1.29.2
Golang == 1.16

Steps to Execute

1. Git clone golang-simple-api-server

git clone {github url here} golang-simple-api-server

2. goto golang-simple-api-server

cd golang-simple-api-server

3. start the postgres and pgweb docker

docker-compose up -d

4. Build the Application

go build -o app 

5. Run the application

./app

Go to your browser : http://127.0.0.1:3000/api/

Available API End Points

GET : http://127.0.0.1:3000/api/status

POST : http://127.0.0.1:3000/api/category

Sample Body

{
    "name": "category1",
    "parent_category": 3
}

GET : http://127.0.0.1:3000/api/categories

POST : http://127.0.0.1:3000/api/product

Sample Body

{
    "name": "product1",
    "price": 100,
    "category_ids": [
        1,
        2
    ]
}

PUT : http://127.0.0.1:3000/api/product

Sample Body

{
    "id": 1,
    "name": "Product1",
    "price": 1200
}

GET : http://127.0.0.1:3000/api//products/{category}

About

A simple Dockerised API server using Golang and PostgreSQL.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published