public class WebServer extends Object
Constructor and Description |
---|
WebServer(WebServerConfig config)
构造函数
|
Modifier and Type | Method and Description |
---|---|
WebServer |
connect(String routeRegexPath,
HttpRouter router)
CONNECT 请求
|
WebServer |
delete(String routeRegexPath,
HttpRouter router)
DELETE 请求
|
WebServer |
get(String routeRegexPath,
HttpRouter router)
GET 请求
|
WebServer |
getAndPost(String routeRegexPath,
HttpRouter router)
同时注册 GET 和 POST 请求
|
HttpDispatcher |
getHttpDispatcher() |
Map<String,Map<String,org.voovan.http.server.RouterWrap<HttpRouter>>> |
getHttpRouters()
获取 Http 的路由配置
|
SocketContext |
getServerSocket() |
SessionManager |
getSessionManager()
返回 Session 管理器
|
WebServerConfig |
getWebServerConfig()
获取 Http 服务配置对象
|
WebServerLifeCycle |
getWebServerLifeCycle() |
WebSocketDispatcher |
getWebSocketDispatcher() |
Map<String,org.voovan.http.server.RouterWrap<WebSocketRouter>> |
getWebSocketRouters()
获取 WebSocket 的路由配置
|
static boolean |
hasAdminRight(HttpRequest request)
是否具备管理权限
这里控制必须是 127.0.0.1的 ip 地址, 并且需要提供 authToken
|
WebServer |
head(String routeRegexPath,
HttpRouter router)
HEAD 请求
|
void |
InitManagerRouter()
初始化服务管理相关的路由
|
void |
initModule()
模块安装
|
boolean |
isServing()
是否处于服务状态
|
static void |
main(String[] args)
启动 WebServer 服务
|
static WebServer |
newInstance()
构建新的 WebServer,从配置文件读取配置
|
static WebServer |
newInstance(File configFile)
构建新的 WebServer,从配置文件中读取配置
方便从集中配置中心加载配置
|
static WebServer |
newInstance(int port)
构建新的 WebServer,指定服务端口
|
static WebServer |
newInstance(String json)
构建新的 WebServer,从配置JSON中读取配置
方便从集中配置中心加载配置
|
static WebServer |
newInstance(String[] args)
启动服务
|
static WebServer |
newInstance(WebServerConfig config)
构建新的 WebServer,从配置对象读取配置
|
WebServer |
options(String routeRegexPath,
HttpRouter router)
OPTIONS 请求
|
WebServer |
otherMethod(String method,
String routeRegexPath,
HttpRouter router)
其他请求
|
void |
pause()
服务暂停
|
WebServer |
post(String routeRegexPath,
HttpRouter router)
POST 请求
|
WebServer |
put(String routeRegexPath,
HttpRouter router)
PUT 请求
|
void |
reload(String reloadInfoJson)
重新读取 WebConfig 的配置
|
WebServer |
serve()
启动服务
阻塞方式启动
|
WebServer |
socket(String routeRegexPath,
WebSocketRouter router)
WebSocket 服务
|
void |
stop()
停止 WebServer
|
WebServer |
syncServe()
启动服务
非阻塞方式启动
|
WebServer |
trace(String routeRegexPath,
HttpRouter router)
TRACE 请求
|
void |
unInitModule()
模块卸载
|
void |
unPause()
服务恢复
|
public WebServer(WebServerConfig config)
config
- WEB 配对对象
异常public SessionManager getSessionManager()
public void initModule()
public void unInitModule()
public WebServerConfig getWebServerConfig()
public HttpDispatcher getHttpDispatcher()
public WebSocketDispatcher getWebSocketDispatcher()
public SocketContext getServerSocket()
public WebServerLifeCycle getWebServerLifeCycle()
public WebServer get(String routeRegexPath, HttpRouter router)
routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer post(String routeRegexPath, HttpRouter router)
routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer getAndPost(String routeRegexPath, HttpRouter router)
routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer head(String routeRegexPath, HttpRouter router)
routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer put(String routeRegexPath, HttpRouter router)
routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer delete(String routeRegexPath, HttpRouter router)
routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer trace(String routeRegexPath, HttpRouter router)
routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer connect(String routeRegexPath, HttpRouter router)
routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer options(String routeRegexPath, HttpRouter router)
routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer otherMethod(String method, String routeRegexPath, HttpRouter router)
method
- 请求方法routeRegexPath
- 匹配路径router
- HTTP处理请求句柄public WebServer socket(String routeRegexPath, WebSocketRouter router)
routeRegexPath
- 匹配路径router
- WebSocket处理句柄public static WebServer newInstance(WebServerConfig config)
config
- WebServer配置类public static WebServer newInstance(String json)
json
- WebServer配置JSONpublic static WebServer newInstance(File configFile)
configFile
- WebServer配置文件public static WebServer newInstance(int port)
port
- HTTP 服务的端口号public static WebServer newInstance()
public void reload(String reloadInfoJson)
reloadInfoJson
- 重新读取 WebConfig 的配置信息public static boolean hasAdminRight(HttpRequest request)
request
- http请求对象public void InitManagerRouter()
public WebServer serve()
public WebServer syncServe()
public Map<String,Map<String,org.voovan.http.server.RouterWrap<HttpRouter>>> getHttpRouters()
public Map<String,org.voovan.http.server.RouterWrap<WebSocketRouter>> getWebSocketRouters()
public boolean isServing()
public void pause()
public void unPause()
public static void main(String[] args)
args
- 启动参数public static WebServer newInstance(String[] args)
args
- 启动参数public void stop()
Copyright © 2020 Voovan. All rights reserved.