Skip to Content

Chapter 5 - Crafting a RESTful application

In this chapter, we will have a look a the principles of RESTful API and learn how to craft one using Spring MVC

In this chapter of Mastering Spring MVC 4, we’ll tackle main principles of a RESTful architecture. We’ll learn how to convert data to JSON and handle different media types in the application.

We will use the JSR-310 (Java DateTime) spec from the get-go and see how to handle them properly in your MVC application.

Forever RESTful

We will see how REST works in theory: HTTP codes and verbs, API versioning, HATEOAS, etc.

Then, we will design an API that uses both JSON and XML to do a twitter search and manage users.

API

Tooling

I will also show you some useful tools to debug REST API. My favorite one is a little command line tool called httpie.

You will study the best practice like exceptions handling and custom error pages.

We will also see how to set up Jackson serialization using mixins and Java 8 dates.

Documentation

We will use swagger to document our API.

Swagger

I hope you will find the content of this chapter interesting, let me know your thoughts in the comments!

comments powered by Disqus