bookshelf

module
v0.0.0-...-a32083c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2018 License: MIT

README

#Bookshelf

This is an example of an API using go-chi. You can use docker-compose to start server with hot reload. Realize is install inside docker to server the API with live reload

Dependencies:

Get Started:


Install

Clone the source into your $GOPATH/src/github.com/MathieuDoyon/bookshelf

git clone git@github.com:MathieuDoyon/bookshelf.git

Setup dependencies (recommended way to install is using dep)

make install
# or use dep
dep ensure

Starting Server

It will start the server into docker with live reload

make serve

If you want to run the server inside your terminal instead of running it into docker, you need have a running instance of mongo and environment var exported.

# Export all environment config to terminal
export $(cat ./.env | xargs)

Using

HTTPie

# Add a new book into bookshelf
http POST :8080/books < ./fixtures/book.json

http POST :8080/books author="Mathieu Doyon" genre=Fiction number_of_pages:=345 publication_year:=2020 rating:=5

# Get list of books
http GET :8080/books/ 

# Get list of book with filters
# All book properties can be added as query string to filter the request.
# author, genre, number_of_pages, publication_year, rating
http GET :8080/books/ rating==4 sort==author direction==-1

# Get a specific book by Mongo Object ID
http GET :8080/books/{ID}

# Update a book
http PUT :8080/books/{ID} genre="SCI FI & FANTASY"


Test

Run test with makefile

make test

TODOs

  • Dockerfile (production)

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL