Permalink
Browse files

Added basic hello program. Added wiki information at README.

  • Loading branch information...
1 parent feb060c commit f4b4da56e43885e3f009678aad4afd61e182ef57 @davidmoreno committed May 9, 2011
Showing with 30 additions and 0 deletions.
  1. +3 −0 README.rst
  2. +1 −0 examples/CMakeLists.txt
  3. BIN examples/basic/basic
  4. +7 −0 examples/hello/CMakeLists.txt
  5. +19 −0 examples/hello/hello.c
View
@@ -15,6 +15,9 @@ Its not a web server per se, as it is not an executable.
If you want to compare to a web server, a web server would use a module or plugin to add
some functionality. With libonion you have the functionality and add the webserver as a plugin.
+There is a wiki available at https://github.com/davidmoreno/onion/wiki, with many useful
+information on how to start and internal workings.
+
API documentation is at http://coralbits.com/staticc/libonion/html/.
SSL Support
@@ -11,3 +11,4 @@ endif (PAM_ENABLED)
add_subdirectory(userver)
add_subdirectory(interactive)
add_subdirectory(fileserver_otemplate)
+add_subdirectory(hello)
View
Binary file not shown.
@@ -0,0 +1,7 @@
+
+add_executable(hello hello.c)
+target_link_libraries(hello onion)
+
+
+
+
@@ -0,0 +1,19 @@
+/** Licensed under AGPL 3.0. (C) 2010 David Moreno Montero. http://coralbits.com */
+#include <onion/onion.h>
+
+int hello(void *p, onion_request *req){
+ onion_response *res=onion_response_new(req);
+ onion_response_set_length(res,11);
+ onion_response_set_header(res, "Content-Type", "text/html");
+ onion_response_write_headers(res);
+ onion_response_write(res,"Hello world",11);
+ return onion_response_free(res);
+}
+
+int main(int argc, char **argv){
+ onion *o=onion_new(O_ONE_LOOP);
+ onion_set_root_handler(o, onion_handler_new((void*)hello, NULL, NULL));
+ onion_listen(o);
+ onion_free(o);
+ return 0;
+}

0 comments on commit f4b4da5

Please sign in to comment.