Bundle HTTP server framework. WebServer registers route handlers for GET/POST/PUT/DELETE, parses query params and multipart form data, and supports OAuth token exchange. Compile with -lib net_server.
WebServer
HTTP and HTTP web server
Operations
Serve # function
Starts a HTTP server that listens for requests
function : Serve(filename:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| filename | String | configuration file (an example) |
Serve # function
Starts a HTTP server that listens for requests
function : Serve(callback:Class, port:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| callback | Class | class inherited from 'HttpRequestHandler' |
| port | Int | server port |
Example
# start an HTTP server on port 8080 using MyHandler
Web.HTTP.Server.WebServer->Serve(MyHandler->New()->GetClass(), 8080, true);Serve # function
Starts a HTTP server that listens for requests
function : Serve(callback:Class, port:Int, is_debug:Bool) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| callback | Class | class inherited from 'HttpRequestHandler' |
| port | Int | server port |
| is_debug | Bool | true for debug output, false otherwise |
ServeSecure # function
Starts a HTTPS server that listens for requests
function : ServeSecure(filename:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| filename | String | configuration file (an example) |
Example
# start an HTTPS server from a JSON config file
Web.HTTP.Server.WebServer->ServeSecure("config/server_config.json");ServeSecure # function
Starts a HTTPS server that listens for requests
function : ServeSecure(callback:Class, port:Int, cert:String, cert_key:String, cert_key_passwd:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| callback | Class | class inherited from 'HttpsRequestHandler' |
| port | Int | server port |
| cert | String | SSL certificate |
| cert_key | String | SSL certificate key |
| cert_key_passwd | String | SSL certificate password |
ServeSecure # function
Starts a HTTPS server that listens for requests
function : ServeSecure(callback:Class, port:Int, cert:String, cert_key:String, cert_key_passwd:String, is_debug:Bool) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| callback | Class | class inherited from 'HttpsRequestHandler' |
| port | Int | server port |
| cert | String | SSL certificate |
| cert_key | String | SSL certificate key |
| cert_key_passwd | String | SSL certificate password |
| is_debug | Bool | true for debug output, false otherwise |
Stop # function
Stops the server
function : Stop() ~ NilExample
# stop a running HTTP or HTTPS server
Web.HTTP.Server.WebServer->Stop();