{ title: 'Embedding GoAhead', crumbs: [ { "Developer's Guide": '../developers/' }, ], }
When embedding GoAhead in your application or system, you have two alternatives:
The GoAhead product includes a fully-featured HTTP server program called goahead that uses the GoAhead HTTP library. You can also modify the goahead.c main program to customize according to your specific requirements. line of code.
You can link the GoAhead library with your application to enable it to listen for HTTP requests and thus become a HTTP server itself. Embedding the GoAhead library is easy and can be done with as little as one line of code.
To include the GoAhead library in your program you need to do the following things:
The GoAhead library also provides an extensive API so you can precisely control how the web server is created and configured.
This example creates a web server using the "server.conf" configuration file and will service events until terminated.
#include "goahead.h" int main(int argc, char **argv) { if (websOpen("web", "route.txt") < 0) { error("Can't open the web server runtime"); return 0; } if (websListen(":80") < 0) { mprError("Can't listen on port 80"); return 0; } websServiceEvents(NULL); websClose(); return 0; }
The GoAhead Javascript web framework allows customization by direct embedding of Javascript code in HTML web pages. This code runs on the server-side before rendering the page to the client.
For more details about the embedding API, please consult the GoAhead API.