init-example.c (976B)
1 /* examples/init-example.c */ 2 3 #include <microhttpd2.h> 4 #include <assert.h> 5 6 static struct MHD_Action * 7 handle_request (void *cls, 8 struct MHD_Request *request, 9 const struct MHD_String *path, 10 enum MHD_HTTP_Method method, 11 uint_fast64_t upload_size) 12 { 13 /* We passed NULL in main() for the closure */ 14 assert (NULL == cls); 15 /* This simply closes the connection after receiving 16 the HTTP header, never return actually returning 17 any data. */ 18 return MHD_action_abort_request (request); 19 } 20 21 22 int 23 main () 24 { 25 struct MHD_Daemon *d; 26 27 /* Create an HTTP server and use "handle_request()" to 28 handle all requests. */ 29 d = MHD_daemon_create (&handle_request, 30 NULL); 31 /* We run with everything on default, so port 80, no TLS */ 32 MHD_daemon_start (d); 33 /* Wait for input on stdin */ 34 (void) getchar (); 35 /* Then just shut everything down */ 36 MHD_daemon_stop (d); 37 return 0; 38 }