Giter Site home page Giter Site logo

hugofmiranda / java-rest-books Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sbouclier/java-rest-books

0.0 0.0 0.0 84 KB

Sample code of DZone article about Spring REST service

Home Page: https://dzone.com/articles/leverage-http-status-codes-to-build-a-rest-service

License: MIT License

Shell 16.58% Java 70.62% Batchfile 12.80%

java-rest-books's Introduction

Build Status Coverage Status

java-rest-books

Sample code of DZone article: https://dzone.com/articles/leverage-http-status-codes-to-build-a-rest-service

Requirements

  • JDK 8
  • Maven 3.x

Setup

Clone the repository:

git clone https://github.com/sbouclier/java-rest-books.git

Go inside the folder:

cd java-rest-books/

Run the application:

mvn clean install spring-boot:run

Open your browser an go to http://localhost:8080/api/books to see some books.

API methods

Create book

curl -X POST --header 'Content-Type: application/json' --header 'Accept: */*' -d '{ \ 
   "authors": [ \ 
     { \ 
       "firstName": "John", \ 
       "lastName": "Doe" \ 
     } \ 
   ], \ 
   "description": "desc", \ 
   "isbn": "123-1234567890", \ 
   "publisher": "My publisher", \ 
   "title": "My book" \ 
 }' 'http://localhost:8080/api/books'

Get a book

curl -X GET --header 'Accept: application/json' 'http://localhost:8080/api/books/978-0321356680'

Update book

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \ 
   "authors": [ \ 
     { \ 
       "firstName": "John", \ 
       "lastName": "Doe" \ 
     } \ 
   ], \ 
   "description": "new desc", \ 
   "isbn": "978-1617292545", \ 
   "publisher": "new publisher", \ 
   "title": "new title" \ 
 }' 'http://localhost:8080/api/books/978-1617292545'

Update a book's description

curl -X PATCH --header 'Content-Type: application/json' --header 'Accept: application/json' -d 'new description' 'http://localhost:8080/api/books/978-1491900864'

Delete a book

curl -X DELETE --header 'Accept: */*' 'http://localhost:8080/api/books/978-1617292545'

Get all books

curl -X GET --header 'Accept: application/json' 'http://localhost:8080/api/books?sort=id&order=asc'

java-rest-books's People

Contributors

sbouclier avatar

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.