@RequestHandler(priority = 990, dynamic = true) public void onRequest(Request.In event) { @SuppressWarnings("PMD.AccessorClassGeneration")
@RequestHandler(dynamic = true) public void onRequest(Request.In event) { if (event.associated(Session.class).isPresent()) {
/** * Handles a `GET` request. * * @param event the event * @param channel the channel * @throws ParseException the parse exception * @throws IOException Signals that an I/O exception has occurred. */ @RequestHandler(dynamic = true) public void onGet(Request.In.Get event, IOSubchannel channel) throws ParseException, IOException { int prefixSegs = resourcePattern.matches(event.requestUri()); if (prefixSegs < 0) { return; } if (contentDirectory == null) { getFromUri(event, channel, prefixSegs); } else { getFromFileSystem(event, channel, prefixSegs); } }
/** * Redirects `GET` requests without trailing slash. * * @param event the event * @param channel the channel * @throws InterruptedException the interrupted exception * @throws IOException Signals that an I/O exception has occurred. * @throws ParseException the parse exception */ @RequestHandler(dynamic = true) @SuppressWarnings("PMD.EmptyCatchBlock") public void onGetRedirect(Request.In.Get event, IOSubchannel channel) throws InterruptedException, IOException, ParseException { HttpResponse response = event.httpRequest().response().get(); response.setStatus(HttpStatus.MOVED_PERMANENTLY) .setContentType("text", "plain", UTF_8) .setField(HttpField.LOCATION, prefix); channel.respond(new Response(response)); try { channel.respond(Output.from(prefix.toString() .getBytes(UTF_8), true)); } catch (UnsupportedEncodingException e) { // Supported by definition } event.setResult(true); event.stop(); }
@RequestHandler(dynamic = true) public void onGet(GetRequest event, IOSubchannel channel) throws InterruptedException, IOException, ParseException {
@RequestHandler(dynamic = true) public void onGet(Request.In.Get event, IOSubchannel channel) throws InterruptedException, IOException, ParseException {
/** * Redirects `GET` requests without trailing slash. * * @param event the event * @param channel the channel * @throws InterruptedException the interrupted exception * @throws IOException Signals that an I/O exception has occurred. * @throws ParseException the parse exception */ @RequestHandler(dynamic = true) @SuppressWarnings("PMD.EmptyCatchBlock") public void onGetRedirect(GetRequest event, IOSubchannel channel) throws InterruptedException, IOException, ParseException { HttpResponse response = event.httpRequest().response().get(); response.setStatus(HttpStatus.MOVED_PERMANENTLY) .setContentType("text", "plain", UTF_8) .setField(HttpField.LOCATION, portal.prefix()); channel.respond(new Response(response)); try { channel.respond(Output.from(portal.prefix().toString() .getBytes(UTF_8), true)); } catch (UnsupportedEncodingException e) { // Supported by definition } event.setResult(true); event.stop(); }