This simple concrete type is able to store both function to pointer or pack instance method id to be used as URL link base. Can be created from pointer to handler or as result of THISLINK or LINK macros.
Handler functions and macros
void RegisterHandler(void (*handler)(Http& http), const char *id, const char *path)
Registers handler function handler with the name id (id is usually the same as the name of function) that is supposed to handle path pattern.
Defines the handler function name (body follows the macro) supposed to handle path pattern.
SKYLARK_PROGRESS(name, path, progressCb)
Defines the handler function name (body follows the macro) supposed to handle path pattern, and setup a progressCb callback to handle progress feedback in lenghty operations.
progressCb must be a pointer to a function with following prototype:
int progressCb(int reason, Http& http, int size);
progressCb is called many times during http transferm, with different reason values :
reason == PROGRESS_HEADERS when headers have been parsed and GET variables are ready
reason == PROGRESS_CONTENT during content transfer, with a frequency depending on TcpSocket WaitTime value (50 Hz by default)
reason == PROGRESS_END when transfer is complete
http is the Http object passed to Skylark handler
size has different meanings, depending on value :
if reason == PROGRESS_HEADERS, size is the total contents size
if reason == PROGRESS_CONTENT, size is the number of bytes transferred
if reason == PROGRESS_END, size has no meaning.
The handler must return a non-zero value (true) if we want to continue transfer, a zero value (false) to abort current transfer.
You can see the SkylarkUpload example demo for usage.
String MakeLink(const HandlerId& id, const Vector<Value>& arg)
Based on handler and arg list of arguments, creates URL would get handled by this handler with specified arguments.
This is the base class of pack classed, which can be used to group and parametrize a set of handlers.
SKYLARK_USE(cls, id, path)
Creates an instance of pack cls as global variable id with path prefix.
Registers a pack handler method to handler path pattern (this is combined with path prefix of SKYLARK_USE). Intended to be used in Use method of pack.
Returns HandlerId of method - to be used within pack class.
Returns HandlerId of specific instance method.
Registers member variable subpack (in Use method).