All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.voovan.http.server.HttpModule Maven / Gradle / Ivy

There is a newer version: 4.3.8
Show newest version
package org.voovan.http.server;

import org.voovan.http.server.context.HttpFilterConfig;
import org.voovan.http.server.context.HttpModuleConfig;
import org.voovan.tools.Chain;

/**
 * WebServer的模块
 *
 * @author helyho
 * 

* Voovan Framework. * WebSite: https://github.com/helyho/Voovan * Licence: Apache v2 License */ public abstract class HttpModule { private WebServer webServer; private HttpModuleConfig moduleConfig; public HttpModule(){ } /** * 初始化模块操作 * @param webServer WebServer对象 * @param moduleConfig 模块配置对象 */ public void init(WebServer webServer, HttpModuleConfig moduleConfig){ this.webServer = webServer; this.moduleConfig = moduleConfig; } /** * 获取模块的配置参数 * @param name 参数名 * @return 参数对象 */ public Object getParamters(String name){ return moduleConfig.getParameters().get(name); } /** * GET 请求 * @param routeRegexPath 匹配路径 * @param router HTTP处理请求句柄 */ public void get(String routeRegexPath, HttpRouter router) { String routePath = moduleConfig.getPath()+routeRegexPath; webServer.get(routePath,router); } /** * POST 请求 * @param routeRegexPath 匹配路径 * @param router HTTP处理请求句柄 */ public void post(String routeRegexPath, HttpRouter router) { String routePath = moduleConfig.getPath()+routeRegexPath; webServer.post(routePath,router); } /** * HEAD 请求 * @param routeRegexPath 匹配路径 * @param router HTTP处理请求句柄 */ public void head(String routeRegexPath, HttpRouter router) { String routePath = moduleConfig.getPath()+routeRegexPath; webServer.head(routePath,router); } /** * PUT 请求 * @param routeRegexPath 匹配路径 * @param router HTTP处理请求句柄 */ public void put(String routeRegexPath, HttpRouter router) { String routePath = moduleConfig.getPath()+routeRegexPath; webServer.put(routePath,router); } /** * DELETE 请求 * @param routeRegexPath 匹配路径 * @param router HTTP处理请求句柄 */ public void delete(String routeRegexPath, HttpRouter router) { String routePath = moduleConfig.getPath()+routeRegexPath; webServer.delete(routePath,router); } /** * TRACE 请求 * @param routeRegexPath 匹配路径 * @param router HTTP处理请求句柄 */ public void trace(String routeRegexPath, HttpRouter router) { String routePath = moduleConfig.getPath()+routeRegexPath; webServer.trace(routePath,router); } /** * CONNECT 请求 * @param routeRegexPath 匹配路径 * @param router HTTP处理请求句柄 */ public void connect(String routeRegexPath, HttpRouter router) { String routePath = moduleConfig.getPath()+routeRegexPath; webServer.connect(routePath,router); } /** * OPTIONS 请求 * @param routeRegexPath 匹配路径 * @param router HTTP处理请求句柄 */ public void options(String routeRegexPath, HttpRouter router) { String routePath = moduleConfig.getPath()+routeRegexPath; webServer.options(routePath,router); } /** * 其他请求 * @param method 请求方法 * @param routeRegexPath 匹配路径 * @param router HTTP处理请求句柄 */ public void otherMethod(String method, String routeRegexPath, HttpRouter router) { String routePath = moduleConfig.getPath()+routeRegexPath; webServer.otherMethod(method,routePath,router); } /** * 获取过滤器链 * @return 过滤器链 */ public Chain filterChain(){ return webServer.getWebServerConfig().getFilterConfigs(); } /** * 安装模块至 WebServer */ public abstract void install(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy