@Override protected void run(final HTTPContext http) throws Exception { // authenticate user http.authenticate(); // analyze input path final RestXqModules rxm = RestXqModules.get(); // select XQuery function RestXqFunction func = rxm.find(http, null); if (func == null) throw HTTPCode.NO_XQUERY.get(); try { // process function that matches the current request func.process(http, null); } catch (final QueryException ex) { // process optional error function func = rxm.find(http, ex.qname()); if (func == null) throw ex; func.process(http, ex); } }