org.tio.http.server.mvc.Routes Java Examples

The following examples show how to use org.tio.http.server.mvc.Routes. 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: DefaultHttpRequestHandler.java    From t-io with Apache License 2.0 6 votes vote down vote up
private void init(HttpConfig httpConfig, Routes routes) throws Exception {
	if (httpConfig == null) {
		throw new RuntimeException("httpConfig can not be null");
	}
	this.contextPath = httpConfig.getContextPath();
	this.suffix = httpConfig.getSuffix();

	if (StrUtil.isNotBlank(contextPath)) {
		contextPathLength = contextPath.length();
	}
	if (StrUtil.isNotBlank(suffix)) {
		suffixLength = suffix.length();
	}

	this.httpConfig = httpConfig;

	if (httpConfig.getMaxLiveTimeOfStaticRes() > 0) {
		staticResCache = CaffeineCache.register(STATIC_RES_CONTENT_CACHENAME, (long) httpConfig.getMaxLiveTimeOfStaticRes(), null);
	}

	sessionRateLimiterCache = CaffeineCache.register(SESSIONRATELIMITER_CACHENAME, 60 * 1L, null);

	this.routes = routes;

	this.monitorFileChanged();
}
 
Example #2
Source File: TioBenchmarkStarter.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param args
 * @author tanyaowu
 * @throws IOException
 */
public static void main(String[] args) throws Exception {
	httpConfig = new HttpConfig(8080, null, null, null);
	httpConfig.setUseSession(false);
	httpConfig.setWelcomeFile(null);
	httpConfig.setCheckHost(false);
	httpConfig.setCompatible1_0(false);

	Routes routes = new Routes(TestController.class);

	requestHandler = new DefaultHttpRequestHandler(httpConfig, routes);
	requestHandler.setCompatibilityAssignment(false);
	httpServerStarter = new HttpServerStarter(httpConfig, requestHandler);
	serverTioConfig = httpServerStarter.getServerTioConfig();
	serverTioConfig.statOn = false;
	httpServerStarter.start();
}
 
Example #3
Source File: TioWebServerBootstrap.java    From tio-starters with MIT License 5 votes vote down vote up
/**
 *  注解包 》 配置包 》 程序所在包
 * */
private void initRoutes() {
    String[] scanPackages = getScanPackages(true);
    if (scanPackages == null || scanPackages.length == 0) {
        //TODO 添加 routes.scanPackages
        if (true) {

        } else {
            scanPackages = getScanPackages(false);
        }
    }
    this.routes = new Routes(scanPackages);
}
 
Example #4
Source File: DefaultHttpRequestHandler.java    From t-io with Apache License 2.0 2 votes vote down vote up
/**
 * 
 * @param httpConfig
 * @param scanRootClasses
 * @param controllerFactory
 * @throws Exception 
 */
public DefaultHttpRequestHandler(HttpConfig httpConfig, Class<?>[] scanRootClasses, ControllerFactory controllerFactory) throws Exception {
	Routes routes = new Routes(scanRootClasses, controllerFactory);
	init(httpConfig, routes);
}
 
Example #5
Source File: DefaultHttpRequestHandler.java    From t-io with Apache License 2.0 2 votes vote down vote up
/**
 * 
 * @param httpConfig
 * @param scanPackages
 * @param controllerFactory
 * @throws Exception 
 */
public DefaultHttpRequestHandler(HttpConfig httpConfig, String[] scanPackages, ControllerFactory controllerFactory) throws Exception {
	Routes routes = new Routes(scanPackages, controllerFactory);
	init(httpConfig, routes);
}
 
Example #6
Source File: DefaultHttpRequestHandler.java    From t-io with Apache License 2.0 2 votes vote down vote up
/**
 * 
 * @param httpConfig
 * @param routes
 * @throws Exception 
 */
public DefaultHttpRequestHandler(HttpConfig httpConfig, Routes routes) throws Exception {
	init(httpConfig, routes);
}