Posts

Showing posts with the label Restful

How to Build a REST API using Dropwizard?

Image
Hello everyone, today we will discuss how to build RESTful API using Dropwizard with the help of one simple example. Dropwizard is an open-source Java framework for the expeditious development of REST APIs.Dropwizard allows a developer to build an initial project very expeditious. This avails the application to be packaged in a way that allows it to be facilely installed on the production environment as a stand-alone service. Dropwizard comes with the fundamental package of components or libraries needed to develop RESTful web services, so you don't require to include and configure each of them discretely: Libraries included inside Dropwizard Jetty :  Dropwizard utilizes the Jetty HTTP library to embed an HTTP server directly into our project. Jersey : It provides support for JAX-RS APIs and serves as a JAX-RS Reference Implementation. Jackson : Jackson is a high-performance JSON processor for Java. Guava : Google's utility library that gives us a large number of classes to sp

Creating a CRUD REST API/Service with Spark

Image
Hello everyone, today we will discuss how to build RESTful API using Spark. Spark is a micro web framework for Java. Spark aims for simplicity and provides only a minimal set of features. However, it provides everything needed to build a web application in a few lines of Java code. Spark is built around Java 8 Lambda Expression philosophy, making it less verbose than most applications inscribed in other Java frameworks. Routes   Let's list the routes that make up our API:  GET /employees — get the list of all employees  GET /employees/:id — get employees with given id  POST /employees/:id — add an employee PUT /employees/:id — edit a particular employee  DELETE /employees/:id — delete a particular employees Let's start to build RSETFul API with Spark Maven Dependencies[pom.xml] <?xml version = "1.0" encoding = "UTF-8" ?> <project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance&