Giter Club home page Giter Club logo

hello-world-jresty's Introduction

hello-world-jresty

how to run

for users

$ wget https://github.com/downgoon/hello-world-jresty/files/1176518/hello-world-jresty-1.1.0.tar.gz
$ tar zxvf hello-world-jresty-1.1.0.tar.gz
$ cd hello-world-jresty-1.1.0

$ jresty start
jresty web app is listening on 8080 ...

$ curl http://localhost:8080/jresty/ping.json -i
some json response

$ jresty stop

if the port 8080 is already used by others, you can change the listening port in hello-world-jresty-1.1.0/tomcat/conf/server.xml

<Connector port="8080 -> ${port}" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

for developers

  • run in eclipse or IntelliJ IDEA

    org.example.jresty.runner.JettyEmbedRunner

  • run with maven

# in rd env (development environment)
mvn -Djetty.port=8080 jetty:run -Dmaven.test.skip=true -Prd

# in op env (production environment)
mvn -Djetty.port=8080 jetty:run -Pop

how to access

multi representation

curl http://localhost:8080/jresty/ping.json -i
curl http://localhost:8080/jresty/ping.jsonp -i
curl http://localhost:8080/jresty/ping.xml -i
curl http://localhost:8080/jresty/ping.html -i
curl http://localhost:8080/jresty/ping.jsp -i

redirect support for .html or .jsp

$ curl http://localhost:8080/jresty/ping.jsp?redirect=http://www.baidu.com -i
HTTP/1.1 302 Found
Content-Language: zh-cn
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Location: http://www.baidu.com?status=200&message=OK
Content-Length: 0
Server: Jetty(7.2.0.v20101020)

$ curl http://localhost:8080/jresty/ping.html?redirect=http://www.baidu.com -i

two URLs for one method

# GET ping.json is equal to GET ping-index.json
# POST ping.json is equal to GET ping-create.json
# DELETE ping.json is equal to GET ping-remove.json
# PUT ping.json is equal to GET ping-update.json
# GET ping/ABC.json is equal to GET ping-view.json?id=ABC

$ curl http://localhost:8080/jresty/ping.json -i
$ curl http://localhost:8080/jresty/ping-index.json -i

some examples

$ curl http://localhost:8080/jresty/ping.json -i
	HTTP/1.1 200 OK
	Content-Language: zh-cn
	Access-Control-Allow-Origin: *
	Content-Length: 97
	Content-Type: application/json;charset=UTF-8
	Cache-Control: max-age=0
	Server: Jetty(7.2.0.v20101020)

$ curl http://localhost:8080/jresty/ping.xml -i
	HTTP/1.1 200 OK
	Content-Language: zh-cn
	Access-Control-Allow-Origin: *
	Content-Length: 200
	Content-Type: application/xml;charset=UTF-8
	Cache-Control: max-age=0
	Server: Jetty(7.2.0.v20101020)

	<io.downgoon.jresty.rest.model.UnifiedResponse>
  		<status>200</status>
  		<message>OK</message>
  		<debug>20161218152559257318:系统正在运行</debug>
	</io.downgoon.jresty.rest.model.UnifiedResponse

hello-world-jresty's People

Contributors

downgoon avatar

Stargazers

 avatar

hello-world-jresty's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.