Search in sources :

Example 1 with PathBindingStorage

use of ratpack.path.internal.PathBindingStorage in project ratpack by ratpack.

the class DefaultContext method start.

public static void start(EventLoop eventLoop, final RequestConstants requestConstants, Registry registry, Handler[] handlers, Action<? super Execution> onComplete) {
    ChainIndex index = new ChainIndex(handlers, registry, true);
    requestConstants.indexes.push(index);
    DefaultContext context = new DefaultContext(requestConstants);
    requestConstants.context = context;
    context.pathBindings = new PathBindingStorage(new RootPathBinding(requestConstants.request.getPath()));
    requestConstants.applicationConstants.execController.fork().onError(throwable -> requestConstants.context.error(throwable instanceof HandlerException ? throwable.getCause() : throwable)).onComplete(onComplete).register(s -> s.add(Context.TYPE, context).add(Request.TYPE, requestConstants.request).add(Response.TYPE, requestConstants.response).add(PathBindingStorage.TYPE, context.pathBindings).addLazy(RequestId.TYPE, () -> registry.get(RequestId.Generator.TYPE).generate(requestConstants.request))).eventLoop(eventLoop).onStart(e -> DefaultRequest.setDelegateRegistry(requestConstants.request, e)).start(e -> {
        requestConstants.execution = e;
        context.joinedRegistry = new ContextRegistry(context).join(requestConstants.execution);
        context.next();
    });
}
Also used : RootPathBinding(ratpack.path.internal.RootPathBinding) ClientErrorHandler(ratpack.error.ClientErrorHandler) DirectChannelAccess(ratpack.handling.direct.DirectChannelAccess) java.util(java.util) Types(ratpack.util.Types) FileSystemBinding(ratpack.file.FileSystemBinding) RootPathBinding(ratpack.path.internal.RootPathBinding) Execution(ratpack.exec.Execution) ResponseTransmitter(ratpack.file.internal.ResponseTransmitter) LoggerFactory(org.slf4j.LoggerFactory) Exceptions.uncheck(ratpack.util.Exceptions.uncheck) TypeToken(com.google.common.reflect.TypeToken) Parser(ratpack.parse.Parser) NoSuchParserException(ratpack.parse.NoSuchParserException) Lists(com.google.common.collect.Lists) PathBindingStorage(ratpack.path.internal.PathBindingStorage) NoSuchRendererException(ratpack.render.NoSuchRendererException) ServerConfig(ratpack.server.ServerConfig) Registry(ratpack.registry.Registry) DefaultRequest(ratpack.http.internal.DefaultRequest) Parse(ratpack.parse.Parse) ratpack.handling(ratpack.handling) ratpack.http(ratpack.http) Path(java.nio.file.Path) HttpHeaderConstants(ratpack.http.internal.HttpHeaderConstants) Function(ratpack.func.Function) ServerErrorHandler(ratpack.error.ServerErrorHandler) RenderController(ratpack.render.internal.RenderController) Logger(org.slf4j.Logger) NotInRegistryException(ratpack.registry.NotInRegistryException) Promise(ratpack.exec.Promise) EventLoop(io.netty.channel.EventLoop) Instant(java.time.Instant) InvalidPathEncodingException(ratpack.path.InvalidPathEncodingException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) IF_MODIFIED_SINCE(io.netty.handler.codec.http.HttpHeaderNames.IF_MODIFIED_SINCE) Channel(io.netty.channel.Channel) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString) Action(ratpack.func.Action) Exceptions(ratpack.util.Exceptions) PathBinding(ratpack.path.PathBinding) ExecController(ratpack.exec.ExecController) PathBindingStorage(ratpack.path.internal.PathBindingStorage)

Aggregations

Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)1 Lists (com.google.common.collect.Lists)1 TypeToken (com.google.common.reflect.TypeToken)1 Channel (io.netty.channel.Channel)1 EventLoop (io.netty.channel.EventLoop)1 IF_MODIFIED_SINCE (io.netty.handler.codec.http.HttpHeaderNames.IF_MODIFIED_SINCE)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 Path (java.nio.file.Path)1 Instant (java.time.Instant)1 java.util (java.util)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 ClientErrorHandler (ratpack.error.ClientErrorHandler)1 ServerErrorHandler (ratpack.error.ServerErrorHandler)1 ExecController (ratpack.exec.ExecController)1 Execution (ratpack.exec.Execution)1 Promise (ratpack.exec.Promise)1 FileSystemBinding (ratpack.file.FileSystemBinding)1 ResponseTransmitter (ratpack.file.internal.ResponseTransmitter)1 Action (ratpack.func.Action)1