io.undertow.attribute.RelativePathAttribute Java Examples

The following examples show how to use io.undertow.attribute.RelativePathAttribute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServletRelativePathAttribute.java    From quarkus-http with Apache License 2.0 6 votes vote down vote up
@Override
public String readAttribute(final HttpServerExchange exchange) {
    ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    if(src == null) {
        return RelativePathAttribute.INSTANCE.readAttribute(exchange);
    }
    String path = (String) src.getServletRequest().getAttribute(RequestDispatcher.FORWARD_PATH_INFO);
    String sp = (String) src.getServletRequest().getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH);
    if(path == null && sp == null) {
        return RelativePathAttribute.INSTANCE.readAttribute(exchange);
    }
    if(sp == null) {
        return path;
    } else if(path == null) {
        return sp;
    } else {
        return sp + path;
    }
}
 
Example #2
Source File: SikulixServer.java    From SikuliX1 with MIT License 6 votes vote down vote up
public ScriptsCommand(TasksCommand tasks) {
  this.taskId = new AtomicInteger();
  this.tasks = tasks;
  this.run.addExceptionHandler(Throwable.class, getExceptionHttpHandler());
  getRouting()
      .add(Methods.GET, "/scripts", 
          getScripts)
      .add(Methods.GET, "/scripts/*",
          Predicates.regex(RelativePathAttribute.INSTANCE, "^/scripts/[^/].*/run$"),
          run)
      .add(Methods.POST, "/scripts/*",
          Predicates.regex(RelativePathAttribute.INSTANCE, "^/scripts/[^/].*/run$"),
          run)
      .add(Methods.POST, "/scripts/*",
          Predicates.regex(RelativePathAttribute.INSTANCE, "^/scripts/[^/].*/task$"),
          task)
      .add(Methods.GET, "/scripts/*",
          Predicates.regex(RelativePathAttribute.INSTANCE, "^/scripts/[^/].*/tasks(/.*)*$"),
          delegate)
      .add(Methods.PUT, "/scripts/*",
          Predicates.regex(RelativePathAttribute.INSTANCE, "^/scripts/[^/].*/tasks(/.*)*$"),
          delegate)
      .add(Methods.GET, "/scripts/*", 
          Predicates.regex(RelativePathAttribute.INSTANCE, "^/scripts/([^/].*)?[^/]$"),
          getScript);
}
 
Example #3
Source File: ServletRelativePathAttribute.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@Override
public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException {
    RelativePathAttribute.INSTANCE.writeAttribute(exchange, newValue);
}
 
Example #4
Source File: ServletRelativePathAttribute.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException {
    RelativePathAttribute.INSTANCE.writeAttribute(exchange, newValue);
}