项目作者: saintlyzero

项目描述 :
POC of REST Api in Java by using jackson which uses JSON as Request and Response Object
高级语言: Java
项目地址: git://github.com/saintlyzero/RESTful-Api-in-Java.git
创建时间: 2018-08-07T16:27:17Z
项目社区:https://github.com/saintlyzero/RESTful-Api-in-Java

开源协议:MIT License

下载


RESTful-Api-in-Java

POC of REST Api in Java by using jackson which uses JSON as Request and Response Object
A DNS Resolver API which return the IP address of the requestes URL


Requires Tomcat 7


JAR Files:


1) asm-all-3.3.1.jar
2) jersey-bundle-1.14.jar
3) json-simple-1.1.1.jar
4) jsr311-api-1.1.1.jar

There’s no need for defining pom.xml if adding the above jar files.


Maven Dependencies:


  1. <dependencies>
  2. <dependency>
  3. <groupId>asm</groupId>
  4. <artifactId>asm-all</artifactId>
  5. <version>3.3.1</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>com.sun.jersey</groupId>
  9. <artifactId>jersey-bundle</artifactId>
  10. <version>1.14</version>
  11. </dependency>
  12. <dependency>
  13. <groupId>com.googlecode.json-simple</groupId>
  14. <artifactId>json-simple</artifactId>
  15. <version>1.1</version>
  16. </dependency>
  17. </dependencies>

Java Files:


1) RESTService

  1. - Creates the REST Service

2) RESTServiceClient

  1. - Calls the REST Service
  2. - Passes JSON Object as Request

3) DnsResolver

  1. - Demo Functionality class
  2. - Resolves IP Address of the specified URL

API URL:


1) http://localhost:8080/RestAPI/api/dns

  1. - Url for the REST Api functionality
  2. - POST
  3. - Request: JSON Object
  4. - Eg:
  5. {
  6. "op":"DNS",
  7. "url":"www.google.com"
  8. }
  9. - Response: JSON Object
  10. -Eg:
  11. {
  12. "ip":"216.58.196.164",
  13. "url":"www.google.com"
  14. }

2) http://localhost:8080/RestAPI/api/verify

  1. - URL to check whether the API is running
  2. - GET
  3. - Response : Text