Giter Club home page Giter Club logo

jaxrs-example's Introduction

A simple example of using Apache CXF and JAX-RS for REST-ful web services. Just a place to hack around, used for some training and discussion on the Kuali Rice team.

Running the Project

You can launch the application from the command line (if you have Maven installed) or from an IDE.

To launch using maven, run the following:

mvn spring-boot:run

To run from an IDE, load the project into your IDE and set up a run configuration for the com.westbrain.sandbox.jaxrs.Application main class.

Using the API

We will use the command line tool curl to exercise the API. If you also want to have pretty printing, install the jq command line tool as well.

Get group 1

curl -D hdr.txt http://localhost:8080/api/v1/groups/1
cat hdr.txt

Pretty print group 1

curl -D hdr.txt -s http://localhost:8080/api/v1/groups/1 | jq "."

Get a group that doesn't exist

curl -D hdr.txt http://localhost:8080/api/v1/groups/500
cat hdr.txt

Get all groups

curl -D hdr.txt -s http://localhost:8080/api/v1/groups | jq "."

Create a new group

curl -D hdr.txt -s -H "Content-Type: application/json" -d '{ "name":"KualiRiceTeam", "description":"The gang of awesome Rice developers!" }' http://localhost:8080/api/v1/groups | jq "."
cat hdr.txt

Update a group

curl -D hdr.txt -s http://localhost:8080/api/v1/groups/11 | jq "."
curl -D hdr.txt -X PUT -H "Content-Type: application/json" -d '{ "id":11, "name":"Eleven!", "description":"This is the new group eleven" }' http://localhost:8080/api/v1/groups/11
cat hdr.txt
curl -D hdr.txt -s http://localhost:8080/api/v1/groups/11 | jq "."

Delete a group

curl -D hdr.txt -s -X DELETE http://localhost:8080/api/v1/groups/11
cat hdr.txt
curl -D hdr.txt http://localhost:8080/api/v1/groups/11
cat hdr.txt

Check the members on group 1

curl -D hdr.txt -s http://localhost:8080/api/v1/groups/1/members | jq "."

Look at a specific member

curl -D hdr.txt -s http://localhost:8080/api/v1/groups/1/members/1 | jq "."

Add a member to group 1

curl -D hdr.txt -s -H "Content-Type: application/json" -d '{ "name":"Eric" }' http://localhost:8080/api/v1/groups/1/members | jq "."
cat hdr.txt
curl -D hdr.txt -s http://localhost:8080/api/v1/groups/1/members | jq "."

Update a member on group 1

curl -D hdr.txt -s http://localhost:8080/api/v1/groups/1/members | jq "."
curl -D hdr.txt -X PUT -H "Content-Type: application/json" -d '{ "id":1, "name":"NewPerson" }' http://localhost:8080/api/v1/groups/1/members/1
cat hdr.txt
curl -D hdr.txt -s http://localhost:8080/api/v1/groups/1/members/1 | jq "."

Delete a member on group 1

curl -D hdr.txt -s http://localhost:8080/api/v1/groups/1/members | jq "."
curl -D hdr.txt -s -X DELETE http://localhost:8080/api/v1/groups/1/members/1
cat hdr.txt
curl -D hdr.txt -s http://localhost:8080/api/v1/groups/1/members | jq "."
curl -D hdr.txt -s http://localhost:8080/api/v1/groups/1/members/1 | jq "."
cat hdr.txt

jaxrs-example's People

Contributors

ewestfal avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.