Coder Social home page Coder Social logo

go_api's Introduction

Build Status codecov reliability rating security rating

Simple GOLang REST API

Simple RESTful API to create, read, update and delete books.

Quick Start

# Make .env file
cp .env.example .env
# Run Docker-compose with PSQL
docker-compose up
# Run migrations
make migrate
# Build app
go build github.com/sotanodroid/GO_API/cmd/goapi

#Or just run pre-built app
./main

Server would be available on port 8000

Endpoints

Get All Books

GET api/books

# Response

[
    {
        "id": 1,
        "isbn": "153223",
        "title": "Book_One",
        "author": {
            "id": 1,
            "firstname": "John",
            "lastname": "Doe"
        }
    },
    {
        "id": 2,
        "isbn": "153235",
        "title": "Book Two",
        "author": {
            "id": 2,
            "firstname": "Steve",
            "lastname": "Smith"
        }
    }
]

Get Single Book

GET api/books/{id}

# Response
{
    "id":1,
    "isbn":"153223",
    "title":"Book_One",
    "author":{
        "id":1,
        "firstname":"John",
        "lastname":"Doe"
    }
}

Delete Book

DELETE api/books/{id}

Response:
"Deleted"

Create Book

POST api/books

# Request sample
{
  "isbn":"4545454",
  "title":"Book Three",
  "author": {
      "firstname":"John",
      "lastname":"Doe"
    }
}

Update Book

PUT api/books/{id}

# Request sample
{
  "isbn":"4545454",
  "title":"Updated Title"
}

Tests:

make test

go_api's People

Contributors

sotanodroid avatar

Stargazers

 avatar  avatar

Watchers

 avatar

go_api's Issues

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.