Reputation: 1005
I want to give nxweb a try. So I successfully got it installed. Unfortunately the documentation is non-existant. After digging around in the code and the INSTALL notes I figured that I had to place my C
file in the modules subdirectory and recompile the main executable via:
gcc -O2 -g main.c modules/*.c -o mynxweb `pkg-config --cflags --libs nxweb`
As this didn't work out I found some code in the main.c
which seems to handle the registration of modules. So I added:
NXWEB_HANDLER_SETUP(my_click, "/click", click, .priority=1000);
and recompiled. It compiles just fine. But I can't find a click.o
(my source file is called click.c
) in the src/bin
directory. The info messages don't mention my module either. So I'm at a loss as to what I am missing.
Maybe we can start a little nxweb noob docu on Stackoverflow.
Upvotes: 4
Views: 750
Reputation: 21476
Basically the procedure is the following:
Build and install nxweb from source. Follow instructions from INSTALL file. This shall install nxweb library.
Write your module. Take bin/modules/hello.c
as example. Make sure you have NXWEB_DEFINE_HANDLER(my_unique_handler_name, ...)
in it.
Build nxweb executable using provided main.c
and your module, link it to nxweb library:
gcc -O2 -g main.c my_module.c -o mynxweb `pkg-config --cflags --libs nxweb`
Configure routing
table in nxweb_config.json by specifying URL prefix that should invoke your handler:
{ "prefix":"/my_handler_url", "handler":"my_unique_handler_name" },
Launch/restart nxweb.
Upvotes: 3
Reputation: 1005
I found it!
You also have to add your module name and the routing path to nxweb_config.json
.
For example:
{ // see modules/click.c
"prefix":"/click", "handler":"click"
},
Upvotes: 1