<
From version < 21.1 >
edited by Ludovic Dubost
on 2010/12/21
To version < 22.1 >
edited by Thomas Mortagne
on 2011/01/04
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ludovic
1 +XWiki.ThomasMortagne
Content
... ... @@ -798,3 +798,32 @@
798 798  ** **Status codes:**
799 799  *** 200: If the request was successful.
800 800  *** 401: If the user is not authorized.
801 +
802 += Custom resources =
803 +
804 +It's possible to easily add any REST resource by registering a ##org.xwiki.rest.XWikiResource## java component on your wiki (see [[Component quide>>DevGuide.WritingComponents]] for more details).
805 +
806 +{code language="java"}
807 +package org.xwiki.contrib.rest;
808 +
809 +import javax.ws.rs.DefaultValue;
810 +import javax.ws.rs.GET;
811 +import javax.ws.rs.Path;
812 +
813 +import org.xwiki.component.annotation.Component;
814 +import org.xwiki.rest.XWikiResource;
815 +
816 [email protected]("org.xwiki.contrib.rest.HelloWordResource")
817 [email protected]("/myresources/{myresourcename}")
818 +class HelloWorldResource extends XWikiResource {
819 + @GET
820 + public String get(@PathParam("myresourcename") @DefaultValue("world") String myresourcename)
821 + {
822 + return "Hello " + myresourcename;
823 + }
824 +}
825 +{/code}
826 +
827 +The name of the component has to be the class FQN.
828 +
829 +You can find more examples on [[https://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-rest/xwiki-rest-server/src/main/java/org/xwiki/rest/resources/]].

Get Connected