use of act.handler.RequestHandler in project actframework by actframework.
the class RouteInfo method of.
public static RouteInfo of(ActionContext context) {
H.Method m = context.req().method();
String path = context.req().url();
RequestHandler handler = context.handler();
if (null == handler) {
handler = UNKNOWN_HANDLER;
}
return new RouteInfo(m, path, handler);
}
use of act.handler.RequestHandler in project actframework by actframework.
the class ActionContext method applyCorsSpec.
public ActionContext applyCorsSpec() {
RequestHandler handler = handler();
if (null != handler) {
CORS.Spec spec = handler.corsSpec();
spec.applyTo(this);
}
applyGlobalCorsSetting();
return this;
}
use of act.handler.RequestHandler in project actframework by actframework.
the class ActionContext method forward.
public void forward(String url) {
E.illegalArgumentIfNot(url.startsWith("/"), "forward URL must starts with single '/'");
E.illegalArgumentIf(url.startsWith("//"), "forward URL must starts with single `/`");
E.unexpectedIfNot(H.Method.GET == req().method(), "forward only support on HTTP GET request");
uploads.clear();
extraParams.clear();
bodyParams = null;
urlPath = UrlPath.of(url);
UndertowRequest req = $.cast(req());
state = State.CREATED;
req.forward(url);
final RequestHandler requestHandler = router.getInvoker(H.Method.GET, url, this);
app().eventBus().emit(new PreHandle(this));
requestHandler.handle(this);
}
use of act.handler.RequestHandler in project actframework by actframework.
the class ResourceGetter method preventFolderAccess.
private boolean preventFolderAccess(URL target, String path, ActionContext context) {
RequestHandler folderHandler = subFolderIndexHandlers.get(path);
if (null != folderHandler) {
folderHandler.handle(context);
return true;
}
if (isFolder(target, path)) {
String indexPath = S.pathConcat(path, SEP, "index.html");
URL indexTarget = ResourceGetter.class.getResource(indexPath);
if (null != indexTarget) {
folderHandler = exists(indexTarget, indexPath) ? new FixedResourceGetter(indexPath) : AlwaysForbidden.INSTANCE;
subFolderIndexHandlers.putIfAbsent(path, folderHandler);
folderHandler.handle(context);
}
return true;
}
return false;
}
use of act.handler.RequestHandler in project actframework by actframework.
the class RouteTableRouterBuilderTest method withBuiltInHandler.
@Test
public void withBuiltInHandler() {
addRouteMap("GET /public file:/public");
RequestHandler h = router.getInvoker(GET, "/public/file1.txt", ctx);
yes(h instanceof FileGetter);
eq(new File("target/test-classes/public"), ActTestBase.fieldVal(h, "base"));
}
Aggregations