Methods
(static) protocol(defaultProtocolopt) → {string}
returns current used protocol
.returns current used protocol
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
defaultProtocol |
string |
<optional> |
if is empty returns configuration default protocol |
Returns:
- Type
- string
close(cb)
close ProxyServer
.close ProxyServer
Parameters:
Name | Type | Description |
---|---|---|
cb |
function | callback receives an error if it occurs |
configuration() → {SGAppsProxy.Config}
returns proxy current configuration
.returns proxy current configuration
Returns:
- Type
- SGAppsProxy.Config
debugEnabled() → {boolean}
check if debug mode is enabled
.check if debug mode is enabled
Returns:
- Type
- boolean
debugEnabled(status) → {boolean}
enable disable debug mode
.enable disable debug mode
Parameters:
Name | Type | Description |
---|---|---|
status |
boolean |
Returns:
- Type
- boolean
error(err)
log a error if debug mode is enabled
.log a error if debug mode is enabled
Parameters:
Name | Type | Description |
---|---|---|
err |
Error |
handleRequest(request, response)
handle for http server request / response
.handle for http server request / response
Parameters:
Name | Type | Description |
---|---|---|
request |
Request | |
response |
Response |
httpServer() → {object}
returns http server user by ProxyServer return type Server
returns http server user by ProxyServer return type Server
Returns:
- Type
- object
isRunning() → {boolean}
check if ProxyServer is running, it returns null if no http server is attached to ProxyServer
.check if ProxyServer is running, it returns null if no http server is attached to ProxyServer
Returns:
- Type
- boolean
log(…items)
logs if debug mode is enabled
.logs if debug mode is enabled
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
items |
any |
<repeatable> |
proxyServer() → {ProxyServer}
return proxy instance
.return proxy instance
Returns:
- Type
- ProxyServer
responseRenderPath(response, path)
render a file in response, file piped to response
.render a file in response, file piped to response
Parameters:
Name | Type | Description |
---|---|---|
response |
Response | |
path |
string |
string2Rule(rule) → {RegExp}
converts a string rule into regular expression ( case sensitive )
.converts a string rule into regular expression ( case sensitive )
Parameters:
Name | Type | Description |
---|---|---|
rule |
string | example "*.sgapps.io" |
Returns:
- Type
- RegExp
Type Definitions
Cache
Properties:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
question |
object | appear after events Properties
|
|||||||||||||||
result |
Array.<SGAppsProxy.ProxyRule> |
Type:
- object
Events
http-request
event id is "http-request--question-constructor"
event id is "http-request--question-constructor"
Parameters:
Name | Type | Description |
---|---|---|
request |
Request | |
response |
Response | |
cache |
module:SGAppsProxy.ProxyServer.Cache |
Fires:
http-request-prepared
event id is "proxy-handler"
event id is "proxy-handler"
Parameters:
Name | Type | Description |
---|---|---|
request |
Request | |
response |
Response | |
cache |
module:SGAppsProxy.ProxyServer.Cache |
Fires:
listening
event id is proxy-upgrade-handler
event id is proxy-upgrade-handler
Parameters:
Name | Type | Description |
---|---|---|
port |
number | |
host |
string |
proxy-error
event is emitted by ProxyInstance
event is emitted by ProxyInstance
Parameters:
Name | Type | Description |
---|---|---|
err |
Error | |
request |
Request | |
response |
Response |
proxy-request
event id is "question-handler"
event id is "question-handler"
Parameters:
Name | Type | Description |
---|---|---|
proxyRequest |
Request | |
request |
Request | |
response |
Response | |
options |
object |
Fires:
- module:SGAppsProxy.ProxyServer.event:proxy-error
- module:SGAppsProxy.ProxyServer.event:http-request-prepared
proxy-upgrade
event id is proxy-upgrade-handler
event id is proxy-upgrade-handler
Parameters:
Name | Type | Description |
---|---|---|
request |
Request | |
response |
Response | |
head |
object | http's server update header http#upgrade event |
Fires:
question-request
event id is "question-handler"
event id is "question-handler"
Parameters:
Name | Type | Description |
---|---|---|
request |
Request | |
response |
Response | |
cache |
module:SGAppsProxy.ProxyServer.Cache |
Fires:
- module:SGAppsProxy.ProxyServer.event:proxy-error
- module:SGAppsProxy.ProxyServer.event:http-request-prepared
question-websocket-request
event id is "question-websocket-handler"
event id is "question-websocket-handler"
Parameters:
Name | Type | Description |
---|---|---|
request |
Request | |
response |
Response | |
cache |
module:SGAppsProxy.ProxyServer.Cache |
Fires:
- module:SGAppsProxy.ProxyServer.event:proxy-error
- module:SGAppsProxy.ProxyServer.event:websocket-request-prepared
websocket-request-prepared
event id is "proxy-handler-websocket"
event id is "proxy-handler-websocket"
Parameters:
Name | Type | Description |
---|---|---|
request |
Request | |
response |
Response | |
head |
object | |
cache |
module:SGAppsProxy.ProxyServer.Cache |