Coder Social home page Coder Social logo

bootlab's Introduction

springboot-rest-lab

Bootstrap project for the Spring Boot REST tutorial found here: https://spring.io/guides/tutorials/bookmarks/

The tutorial includes four main steps:

  • Building the model
  • Building a REST service
  • Building a HATEOAS REST Service
  • Securing a REST Service

Each step is executed in a separate module of the project.

This project contains the four modules (model, rest, hateoas, security) and complete build.gradle file and can be used as a starting point when following the tutorial.

Run application

The REST, HATEOAS and security step/module contains an Application class with a main method starting the application.

The application in each step can be started either by running the Application class from your IDE or with Gradle. To do the latter just run the below command for the module you want to start, for example:

./gradlew :rest:bootRun

Test application with cURL

You can use cURL to test your application at the different steps. Some example commands follows.

REST/HATEOAS

Get all bookmarks for user jhoeller:

curl -v GET http://127.0.0.1:8080/jhoeller/bookmarks

Add a new bookmark for user jhoeller:

curl -X POST -v -H "Content-Type: application/json" -d '{"uri":"the uri", "description":"the description"}' http://127.0.0.1:8080/jhoeller/bookmarks

NB! Windows users might need to escape double quotes in the json.

Security

  1. Login / get access token for user jhoeller:

     curl -X POST -vu android-bookmarks:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=password&username=jhoeller&grant_type=password&scope=write&client_secret=123456&client_id=android-bookmarks"
    
  2. Get all bookmarks (for user jhoeller):

     curl -v GET http://127.0.0.1:8080/bookmarks  -H "Authorization: Bearer [access_token from response in above POST request]"
    

    (NB! The second example request at the top of the security step Application class in the tutorial is incorrect.)

Learn more about Spring Boot

http://projects.spring.io/spring-boot/

http://www.infoq.com/articles/microframeworks1-spring-boot

bootlab's People

Watchers

Pavel Rozenblioum 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.