Table of contents
Using Armeria's annotations, you can build RESTful services on the go. Through this tutorial, you'll learn to build a RESTful service with Armeria. In particular, you'll be using these Armeria features:
This tutorial is based on a sample service, a minimal blog service, with which you can create, read, update, and delete blog posts. To keep our focus on Armeria, this tutorial and the sample service use memory-based operations instead of database operations.
This tutorial assumes that you have:
- Experience in building services in Java
- Experience in Java frameworks for server-side programming
- Understanding of RESTful APIs and how to implement them
To run and develop the sample service, set your computer with the requirements:
- JDK 11 or higher
- Gradle: Set your Gradle to compile Java with the -parameters option
The sample service provides you implementations of CRUD operations as specified below.
The sample service code consists of the following folders and files.
Here is a part of the build.gradle file for the sample service. If you are trying the tutorial from scratch, base your file on the sample service's.
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
Have a go at running the sample service and experience the outcome of this tutorial. Using Armeria's Documentation Service, you can see a server running, receiving requests and sending responses.
- Download the code from here.
- Build the sample service using the Gradle Wrapper.
$ ./gradlew build
- Run the sample service again, using the Gradle Wrapper.
$ ./gradlew run
- Open the Documentation service page on your web browser at http://127.0.0.1:8080/docs.
Try writing the blog service yourself by following the guides in the given order: