Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ratpack.handling.internal;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.reflect.TypeToken;
import io.netty.channel.Channel;
import io.netty.channel.EventLoop;
import io.netty.handler.codec.http.HttpResponseStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ratpack.error.ClientErrorHandler;
import ratpack.error.ServerErrorHandler;
import ratpack.exec.ExecController;
import ratpack.exec.Execution;
import ratpack.exec.Promise;
import ratpack.file.FileSystemBinding;
import ratpack.file.internal.ResponseTransmitter;
import ratpack.func.Action;
import ratpack.func.Block;
import ratpack.func.Function;
import ratpack.handling.*;
import ratpack.handling.direct.DirectChannelAccess;
import ratpack.http.Request;
import ratpack.http.Response;
import ratpack.http.TypedData;
import ratpack.http.internal.DefaultRequest;
import ratpack.http.internal.HttpHeaderConstants;
import ratpack.parse.NoSuchParserException;
import ratpack.parse.Parse;
import ratpack.parse.Parser;
import ratpack.path.PathBinding;
import ratpack.path.PathTokens;
import ratpack.path.internal.PathBindingStorage;
import ratpack.path.internal.RootPathBinding;
import ratpack.registry.NotInRegistryException;
import ratpack.registry.Registry;
import ratpack.registry.internal.DelegatingRegistry;
import ratpack.registry.internal.TypeCaching;
import ratpack.render.NoSuchRendererException;
import ratpack.render.internal.RenderController;
import ratpack.server.ServerConfig;
import ratpack.util.Exceptions;
import ratpack.util.Types;
import java.lang.reflect.UndeclaredThrowableException;
import java.nio.file.Path;
import java.util.*;
import static com.google.common.base.Throwables.getStackTraceAsString;
import static io.netty.handler.codec.http.HttpHeaderNames.IF_MODIFIED_SINCE;
import static io.netty.handler.codec.http.HttpResponseStatus.NOT_MODIFIED;
import static ratpack.util.Exceptions.uncheck;
public class DefaultContext implements Context {
private static final TypeToken> PARSER_TYPE_TOKEN = TypeCaching.typeToken(new TypeToken>() {});
private final static Logger LOGGER = LoggerFactory.getLogger(DefaultContext.class);
public static Context current() {
return Execution.current().get(Context.TYPE);
}
public static class ApplicationConstants {
private final RenderController renderController;
private final ExecController execController;
private final ServerConfig serverConfig;
private final Handler end;
public ApplicationConstants(Registry registry, RenderController renderController, ExecController execController, Handler end) {
this.renderController = renderController;
this.execController = execController;
this.serverConfig = registry.get(ServerConfig.TYPE);
this.end = end;
}
}
public static class RequestConstants implements DirectChannelAccess {
private final ApplicationConstants applicationConstants;
private final DefaultRequest request;
private final Channel channel;
private final ResponseTransmitter responseTransmitter;
private final Action> onTakeOwnership;
private Execution execution;
private final Deque indexes = new ArrayDeque<>();
public Response response;
public Context context;
public Handler handler;
public RequestConstants(ApplicationConstants applicationConstants, DefaultRequest request, Channel channel, ResponseTransmitter responseTransmitter, Action> onTakeOwnership) {
this.applicationConstants = applicationConstants;
this.request = request;
this.channel = channel;
this.responseTransmitter = responseTransmitter;
this.onTakeOwnership = onTakeOwnership;
}
@Override
public Channel getChannel() {
return channel;
}
@Override
public void takeOwnership(Action