.setMatchingMode(Template.MODE_EQUALS); Directory alljobsdir = new Directory( getContext(), engine.getJobsDir().toURI().toString()); alljobsdir.setListingAllowed(true); router.attach("/engine/jobsdir",alljobsdir); Directory staticDir = new Directory(getContext(),resource); router.attach("/engine/static/",staticDir);
String rootUri = "file:///(...)/static-content"; Directory directory = new Directory(getContext(), rootUri); directory.setListingAllowed(true); router.attach("/static/", directory);
rootDir.setListingAllowed( false ); rootDir.setNegotiateContent( false ); attach( root, false, "/", rootDir );
/** * Sets the reference comparator based on the more friendly "Alphanum * Algorithm" created by David Koelle. The internal implementation used is * based on an optimized public domain implementation provided by Rob * Heittman from the Solertium Corporation. * * @see <a href="http://www.davekoelle.com/alphanum.html">The original * Alphanum Algorithm from David Koelle</a> * @see #setComparator(Comparator) */ public void setAlphaNumComparator() { setComparator(new AlphabeticalComparator()); }
@Override public Handler findTarget( Request request, Response response ) { StaticHeaderUtil.addResponseHeaders( response ); return super.findTarget( request, response ); } }
/** * Finds the target handler if available. * * @param request * The request to filter. * @param response * The response to filter. * @return The target handler if available or null. */ @Override public Handler findTarget(Request request, Response response) { try { return Engine.getInstance().createDirectoryResource(this, request, response); } catch (IOException ioe) { getLogger().log(Level.WARNING, "Unable to find the directory's resource", ioe); return null; } }
public class FileApplication extends Application { // for example: public static final String ROOT_URI = // "file:///C:/restlet-jee-2.0.6/docs/api/"; @Override public synchronized Restlet createInboundRoot() { String ROOT_URI = "file:///" + Environment.getExternalStorageDirectory() + "/"; Directory directory = new Directory(getContext(), LocalReference.localizePath(ROOT_URI)); directory.setListingAllowed(true); Router router = new Router(getContext()); router.attach("/files", directory); return router; } }
/** * Sets the reference comparator based on classic alphabetical order. * * @see #setComparator(Comparator) */ public void setAlphaComparator() { setComparator(new AlphabeticalComparator()); }
.setMatchingMode(Template.MODE_EQUALS); Directory alljobsdir = new Directory( getContext(), engine.getJobsDir().toURI().toString()); alljobsdir.setListingAllowed(true); router.attach("/engine/jobsdir",alljobsdir); Directory staticDir = new Directory(getContext(),resource); router.attach("/engine/static/",staticDir);
@Override public synchronized Restlet createInboundRoot() { Directory directory = new Directory(getContext(), LocalReference.createFileReference("/home/florian/dev/wkspace/myproject/src/main/webapp/public")); directory.setListingAllowed(true); Router router = new Router(getContext()); router.attachDefault(new HomeApplication()); router.attach("/static", directory); router.attach("/hello", new HelloWorldApplication()); return router; }