Coder Social home page Coder Social logo

abhimartin / restful-blog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from frapalop/restful-blog

0.0 2.0 0.0 205 KB

This is a sample application written in Java and Spring Framework which demonstrates how to create a RESTful Web Service.

Home Page: http://restful-blog.cloudfoundry.com/

Java 100.00%

restful-blog's Introduction

Blog RESTful Web Service Sample

##Introduction

This is a very basic sample application written in Java and Spring Framework which demonstrates how to create a RESTful Web Service.

This sample RESTful web service contains simple Blog resources like Author, Post, and Categories. I will be posting a tutorial on how to create RESTful Web Services on my blog No-nonsense.

##Deployment

This application is already deployed on Cloud Foundry. You can play with it by going to https://restful-blog.cloudfoundry.com/.

##How to use the deployed application

This sample RESTful web service is secured by Spring Security. If asked for credentials, just enter admin for User and admin for Password. I will also post a tutorial on my blog on securing RESTful Web Services.

Working with Authors

####GET /resources/author

  • will lists all authors

####GET /resources/author/{id}

  • will return the author with the specified ID

####GET /resources/author/{id}/posts

  • will return a list of the posts made by the author with the specified ID

####POST /resources/author

  • will create an author in the database

Parameters:

  • username {String} - username for the author. Used to login.
  • email {String} - email of the author
  • password {String} - password for the author. Used to login.
  • firstName {String} - Author's First Name
  • lastName {String} - Author's Last Name

Sample Request Body

{
	"username": "user",
	"password": "user",
	"email": "[email protected]",
	"firstName": "Benj",
	"lastName": "Sicam"
}

####PUT /resources/author

  • will update the author in the database

Parameters

  • id {String} - id of the author to be updated.
  • username {String} - username for the author. Used to login.
  • email {String} - email of the author
  • firstName {String} - Author's First Name
  • lastName {String} - Author's Last Name

Sample Request Body

{
	"id": "1",
	"username": "user",
	"email": "[email protected]",
	"firstName": "Juan",
	"lastName": "dela Cruz"
}

####DELETE /resources/author/{id}

  • will delete the author with the specified ID in the database

###Working with Categories

####GET /resources/category

  • will lists all authors

####GET /resources/category/{id}

  • will return the category with the specified ID

####GET /resources/category/{id}/posts

  • will return a list of the posts under the specified category ID

####POST /resources/category

  • will create a category in the database

Parameters:

  • name {String} - name of the category

Sample Request Body

{
	"name": "My Category"
}

####PUT /resources/category

  • will update the category in the database

Parameters:

  • id {String} - the id of the category to be updated.
  • name {String} - updated name of the category

Sample Request Body

{
	"id": "1",
	"name": "My Category"
}

####DELETE /resources/category/{id}

  • deletes the category with the specified ID

###Working with Posts

####GET /resources/post

  • will list all posts

####GET /resources/post/{id}

  • will return the post with the specified ID

####GET /resources/post/{id}/author

  • will return the author of the post with the specified id

####GET /resources/post/{id}/category

  • will return a list of categories in which the post with the specified id is under

####POST /resources/post

  • will create a new post in the database

Parameters:

  • author {Object} - an object which references an author. ID field in the only required field.
  • date {String} - format is YYYY-MM-DD
  • categories {Array} - An array of objects containing category IDs
  • content {String} - content for the post

Sample Request Body

{
	"author": {
		"id": "1"
	},
	"date": "2013-05-07",
	"categories": [
		{
			"id": "1"
		},
		{
			"id": "3"
		}
	],
	"content": "My content"
}

####PUT /resources/post

  • will update a post on the database

Parameters:

  • id {String} - the ID of the post to be updated
  • author {Object} - an object which references an author. ID field in the only required field.
  • date {String} - format is YYYY-MM-DD
  • categories {Array} - An array of objects containing category IDs
  • content {String} - content for the post

Sample Request Body

{
	"id": "1",
	"author": {
		"id": "1"
	},
	"date": "2013-05-07",
	"categories": [
		{
			"id": "1"
		},
		{
			"id": "3"
		}
	],
	"content": "My updated content"
}

####DELETE /resources/post/{id}

  • deletes the post with the specified ID

restful-blog's People

Watchers

James Cloos avatar Abhinav 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.