Re: {nxweb} Beginner's question as to how add custom modules.

98 views
Skip to first unread message

Yaroslav

unread,
Oct 9, 2013, 3:03:04 PM10/9/13
to nx...@googlegroups.com
Hi,

I see you have already found the missing bit on SO. Basically the procedure is the following:

0) Build and install nxweb from source. This shall install nxweb library.

1) Write your module. Take bin/modules/hello.c as example. Make sure you have NXWEB_DEFINE_HANDLER(my_unique_handler_name, ...) in it.

2) 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`

3) 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"
},

4) Launch/restart nxweb.

I've posted this to SO as well.

Yaroslav



On Wed, Oct 9, 2013 at 7:12 PM, Sören Titze <4th...@googlemail.com> wrote:
Hi,

I started a question on Stackoverflow asking how to add a custom module. It can be found here: http://stackoverflow.com/questions/19275869/adding-a-module-in-nxweb. I will copy the question here but it would still be cool if any of you nxweb veterans could head over to SO and post an answer.

The question is this:

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.

Thanks for you help!

--
You received this message because you are subscribed to the Google Groups "nxweb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nxweb+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sören Titze

unread,
Oct 9, 2013, 4:49:19 PM10/9/13
to nx...@googlegroups.com
Yes, perfect answer. I like nxweb quite a lot I've been able to get my module running pretty fast. Especially compared to nginx. I also tried G-WAN but the way linking libraries is handled is very strange and the fact that its closed source pretty much killed it for me. When I have more basic questions I will try and post them on SO and here. I think there reason why not more people are using your server is the lack of documentation. Maybe SO is a good starting point to build at least the basics for everyone who is interested.

Regards,
Sören
Reply all
Reply to author
Forward
0 new messages