19.0.0 released Nov 08, 2023
Startup handler

Purpose: Execute your code once before any request handlers do.

void _startup ( ) ...

To specify your code to execute once before any requests are handled, create a source file "_startup.vely" and implement a function "void _startup()", which will be automatically picked up and compiled with your application.

Startup handler will execute just before the first request. It will not execute when the application starts, but when it receives the very first request.

Important: if you need cross-request global variables that would be available for the life of the process, i.e. to any request served by this process, do not use result(s) of any Vely statements, because such memory is released at the end of each request, and thus would become invalid after very first request served by this process. If you must, you can use either global variables or use C's "malloc()" functions. Note however, that this is rarely needed and generally should be avoided.
Examples
Here is a simple implementation of startup handler that just outputs "Hi there!!":
#include <vely.h>

void _startup()
{
    out-header default
    @Hi there!!
}

See also
Requests
after-request-handler  
before-request-handler  
building-URL  
getting-URL  
global-request-data  
non-request  
normalized-URL  
request  
request-handler  
request-URL  
startup-handler  
vely-dispatch-request    
See all
documentation


You are free to copy, redistribute and adapt this web page (even commercially), as long as you give credit and provide a dofollow link back to this page - see full license at CC-BY-4.0. Copyright (c) 2019-2023 Dasoftver LLC. Vely and elephant logo are trademarks of Dasoftver LLC. The software and information on this web site are provided "AS IS" and without any warranties or guarantees of any kind. Icons from table-icons.io copyright PaweĊ‚ Kuna, licensed under MIT license.