org.yx.http.start.JettyHandlerSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sumk Show documentation
Show all versions of sumk Show documentation
A quick developing framewort for internet company
/**
* Copyright (C) 2016 - 2030 youtongluan.
*
* 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 org.yx.http.start;
import java.util.Objects;
import java.util.function.Supplier;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.server.session.SessionHandler;
import org.yx.conf.AppInfo;
public class JettyHandlerSupplier {
private static Supplier gzipHandlerSupplier = () -> {
GzipHandler h = new GzipHandler();
h.addIncludedMethods("POST");
h.setMinGzipSize(AppInfo.getInt("sumk.jetty.gzip.minsize", 1000));
return h;
};
private static Supplier resourceHandlerSupplier = () -> {
ResourceHandler handler = new ResourceHandler();
String welcomes = AppInfo.get("sumk.jetty.resource.welcomes");
if (welcomes != null && welcomes.length() > 0) {
handler.setWelcomeFiles(welcomes.replace(',', ',').split(","));
}
return handler;
};
private static Supplier sessionHandlerSupplier = SessionHandler::new;
public static Supplier gzipHandlerSupplier() {
return gzipHandlerSupplier;
}
public static void setGzipHandlerSupplier(Supplier h) {
JettyHandlerSupplier.gzipHandlerSupplier = Objects.requireNonNull(h);
}
public static Supplier resourceHandlerSupplier() {
return resourceHandlerSupplier;
}
public static void setResourceHandlerSupplier(Supplier h) {
JettyHandlerSupplier.resourceHandlerSupplier = Objects.requireNonNull(h);
}
public static Supplier sessionHandlerSupplier() {
return sessionHandlerSupplier;
}
public static void setSessionHandlerSupplier(Supplier h) {
JettyHandlerSupplier.sessionHandlerSupplier = Objects.requireNonNull(h);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy