This section describes a very simple Service function called simple_service. This function sends a message in response to a client request. The message is initialized by the init_simple_service function during server initialization.
To load the shared object containing your functions, add the following directive in the Init section of the magnus.conf file:
Init fn=load-modules shlib=yourlibrary funcs=simple-service-init,simple-service |
To call the simple-service-init function to initialize the message representing the generated output, add the following directive to the Init section in magnus.conf. This directive must come after the directive that loads the library containing simple-service-init.
Init fn=simple-service-init generated-output="<H1>Generated-output-msg</H1>" |
To execute the custom SAF during the request-response process for an object, add the following code to that object in the obj.conf file:
Service type="text/html" fn=simple-service
The type="text/html" argument indicates that this function is invoked during the Service stage only if the content-type has been set to text/html.
The source code for this example is in the service.c file in the install-dir/samples/nsapi directory.