Skip to content

xrkhill/libraria

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libraria

Libraria is a sample REST API for books.

Running

Tested with Go 1.13.x. Uses Go Modules.

go test ./...
go run main.go

API

Following are some example API requests and responses.

POST /books

Create a book.

Request

curl -s -X POST http://localhost:8080/books -H "Content-Type: application/json" -d "@book_00.json"
curl -s -X POST http://localhost:8080/books -H "Content-Type: application/json" -d "@book_01.json"

Response

{
  "author": "George Orwell",
  "title": "1984",
  "ISBN": "9780451524935",
  "language": "English",
  "published": "1961-01-01T00:00:00Z",
  "listPrice": 999
}

GET /books

Read all books.

Request

curl -s -X GET http://localhost:8080/books

Response

{
  "9780451524935": {
    "author": "George Orwell",
    "title": "1984",
    "ISBN": "9780451524935",
    "language": "English",
    "published": "1961-01-01T00:00:00Z",
    "listPrice": 999
  },
  "9780553380163": {
    "author": "Stephen Hawking",
    "title": "A Brief History of Time",
    "ISBN": "9780553380163",
    "language": "English",
    "published": "1998-09-01T00:00:00Z",
    "listPrice": 1800
  }
}

GET /books/:isbn

Read one book.

Request

curl -s -X GET http://localhost:8080/books/9780451524935

Response

{
  "author": "George Orwell",
  "title": "1984",
  "ISBN": "9780451524935",
  "language": "English",
  "published": "1961-01-01T00:00:00Z",
  "listPrice": 999
}

PUT /books

Update a book.

Request

curl -s -X PUT http://localhost:8080/books -H "Content-Type: application/json" -d "@book_01.json"

Response

{
  "author": "Stephen Hawking",
  "title": "A Brief History of Time",
  "ISBN": "9780553380163",
  "language": "English",
  "published": "1998-09-01T00:00:00Z",
  "listPrice": 1800
}

DELETE /books/:isbn

Delete a book.

Request

curl -s -X DELETE http://localhost:8080/books/9780451524935

Response

{}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages