neelgajjar / Messenger-RESTful-API

REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RESTful-Messenger

This is a simple messenger app that allows a user to post a message, update a message, delete a message and determine whether a particular message is palindromic or not.

RESTful-API

#Implementation Architecutre This project is created using the latest Jave EE Eclipse Mars IDE. I used a Maven project in order to facilitate the task of including the necessary dependancies, namely the 'Jersey' dependancies for taking care of the RESTful component of the project (handling HTTP requests, taking care of path parameters, returning XML and/or JSON responses), and the 'AWS-Java-SDK' to help deploy the application on an AWS instance. The eclipse AWS toolkit is also crucial for deployment. The following diagram provides an illustration. alt tag

#Use cases alt tag alt tag NOTES:

  • This assumes that the user is typing a proper URI
  • An invalid ID refers to an ID of a message that does not exist

#Deployment Luckily for me, as this is my first time to, a) create a RESTful API, and, b) use AWS, eclipse makes the process of deploying on an EC2 instance simple and easy.

  1. Firstly, I had to connect the Maven project to my newly created AWS account. To do so, I went to the AWS toolkit tab in the 'Preferences' window, entered my 'Access Key ID' and 'Secret Access Key'. In order to launch an EC2 instance, I also had to type in my 'AWS Account Number' and provide the paths to the certificate and private key files.

  2. Now it's time to configure an AWS server and launch it. The following screenshots visualize the process. alt tag alt tag alt tag

  3. Finally, an EC2 instance launches and it is displayed on the the AWS console as well as on the eclipse interface itself. alt tag

alt tag

NOTE: upon configuring an AWS server, you are given the option of creating a new key pair or using an already existing one. Since I did not have an already existing pair, I created a new one and named it 'messengerPair'.

Once the application is deployed, a public DNS is provided. The one produced by my EC2 instance is: http://messengerenvironment-exhtahi7nu.elasticbeanstalk.com

#REST API Documentation I used 'Postman' (a chrome plugin) to test the GET, POST, PUT and DELETE requests. Here's a screenshot: alt tag

Here's how to use the GET, POST, PUT and DELETE requests:

  • GET .../MessengerAPI/messages => to retrieve all the messages
  • GET .../MessengerAPI/messages/id => to retrieve message with id and see if it's plaindromic or not
  • POST .../MessengerAPI/messages => to post a message. The message should be provided in the body in a json format
  • PUT .../MessengerAPI/messages/id => to replace message with id with a new message provided in the body in a json format
  • DELETE .../MessengerAPI/messages/id => to delete message with id

DELETE

MESSAGE

http://localhost:8080/RESTfulMessenger/restapi/messages/{messageId}

PROFILE

http://localhost:8080/RESTfulMessenger/restapi/profiles/{profilename}

About

REST API

License:MIT License


Languages

Language:Java 99.8%Language:HTML 0.2%