Skip to content

Instantly share code, notes, and snippets.

@mjpitz
Created February 6, 2014 17:19
Show Gist options
  • Save mjpitz/8848611 to your computer and use it in GitHub Desktop.
Save mjpitz/8848611 to your computer and use it in GitHub Desktop.
Fully stubbed out REST controller for Spring MVC
package com.example.controllers;
import com.example.models.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author pitz@indeed.com
*/
@RestController
@RequestMapping(value="/resource")
public class ResourceController {
/**
* @return
*/
@RequestMapping(method= RequestMethod.GET)
public List<Resource> index() {
throw new UnsupportedOperationException();
}
/**
* @return
*/
@RequestMapping(value="/create", method=RequestMethod.GET)
public Resource create() {
throw new UnsupportedOperationException();
}
/**
* @return
*/
@RequestMapping(method=RequestMethod.POST)
public Resource store() {
throw new UnsupportedOperationException();
}
/**
*
* @param id The id for the resource
* @return
*/
@RequestMapping(value="/{id}", method=RequestMethod.GET)
public Resource show(@PathVariable final String id) {
throw new UnsupportedOperationException();
}
/**
*
* @param id The id for the resource
* @return
*/
@RequestMapping(value="/{id}/edit", method=RequestMethod.GET)
public Resource edit(@PathVariable final String id) {
throw new UnsupportedOperationException();
}
/**
*
* @param id The id for the resource
* @return
*/
@RequestMapping(value="/{id}", method={RequestMethod.PUT, RequestMethod.PATCH})
public Resource update(@PathVariable final String id) {
throw new UnsupportedOperationException();
}
/**
* Delete a request from the database
*
* @param id The id for the resource
* @return The request that was deleted from the database
*/
@RequestMapping(value="/{id}", method=RequestMethod.DELETE)
public Resource delete(@PathVariable final String id) {
throw new UnsupportedOperationException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment