WebServer

Namespace: dmWebServer Language: C++ Type: Defold C++ File: webserver.h Source: engine/dlib/src/dmsdk/dlib/webserver.h Include: dmsdk/dlib/webserver.h

Simple high-level single-threaded Web server based on dmHttpServer The web-server has a handler concept similar to servlets in Java

API

AddHandler

Type: FUNCTION Requests use the handler with the longest matching prefix, regardless of registration order. A handler registered at “/” serves as a fallback. Equivalent to calling the four-argument overload with openapi_json set to 0.

Parameters

Returns

AddHandler

Type: FUNCTION Requests use the handler with the longest matching prefix, regardless of registration order. A handler registered at “/” serves as a fallback. Pass 0 to register without documenting the handler. Otherwise, the OpenAPI JSON is a non-empty Paths Object describing the paths and methods served by this handler. Each path must start with the handler’s prefix and must not already be documented by another handler. Schemas should be inline or use references to paths in the resulting document. The server retains the JSON pointer without copying it. Keep the string unchanged and valid until the handler is removed or the server is deleted; a static const char array is recommended.

Parameters

Returns

GetHeader

Type: FUNCTION Get http header value for key, ignoring ASCII case in the header name

Parameters

Returns

Handler

Type: TYPEDEF Web request handler callback

Parameters

Returns

HandlerParams

Type: STRUCT handler parameters

Members

HServer

Type: TYPEDEF web server handle

Receive

Type: FUNCTION Receive data

Parameters

Returns

RemoveHandler

Type: FUNCTION Remove handle

Parameters

Returns

Request

Type: STRUCT web server request

Members

Result

Type: ENUM result codes

Members

Send

Type: FUNCTION Copies data into an owned response sent asynchronously after the handler returns. Socket errors are handled by the server; RESULT_OK means the data was queued.

Parameters

Returns

SendAttribute

Type: FUNCTION Sends a header attribute

Parameters

Returns

SetStatusCode

Type: FUNCTION Set response status code.

Notes

Parameters

Returns

WEBSERVER_CONTEXT_NAME

Type: CONSTANT Name used when registering the web server with the engine context registry.