Skip to content

Instantly share code, notes, and snippets.

@jagregory
Created April 11, 2011 21:11
Show Gist options
  • Save jagregory/914355 to your computer and use it in GitHub Desktop.
Save jagregory/914355 to your computer and use it in GitHub Desktop.
@Path("/customers")
class CustomerResource {
@GET
@Produces(Array(MediaType.APPLICATION_JSON))
@Path("{id}")
def getJson(@PathParam("id") id: Int) =
"Id requested was: " + id.toString()
}
@jagregory
Copy link
Author

My eyes!

  • @GET could be inferred from the get in the method name.
  • The @Produces JSON could be inferred from the Json part of the method name.
  • @Path("{id}") and @PathParam("id") could both be inferred from the name of the method parameter.

facepalm

@mxriverlynn
Copy link

this is java, right? you're lucky you don't have to specify @Get, @Path, etc somewhere in 300 lines of XML :)

@jagregory
Copy link
Author

Java, yeah. The more "modern" frameworks seem to be leaving XML behind in favour for Annotations/Attributes. One step forward, two steps back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment