Github User Fetcher 1.0.0
C Application with Server and GUI
|
Implements a simple HTTP server using Civetweb to serve GitHub user information. More...
#include "server.h"
#include "../vendor/civetweb/civetweb.h"
#include "user.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Go to the source code of this file.
Functions | |
static int | user_handler (struct mg_connection *conn, void *cbdata) |
HTTP request handler for user lookup. | |
void | start_http_server (int port) |
Starts an HTTP server on the specified port. | |
Implements a simple HTTP server using Civetweb to serve GitHub user information.
Definition in file server.c.
void start_http_server | ( | int | port | ) |
Starts an HTTP server on the specified port.
Starts the HTTP server.
Configures Civetweb with basic options and handles incoming user requests. The server runs indefinitely until manually interrupted.
port | The TCP port to listen on. |
Definition at line 59 of file server.c.
References mg_context::callbacks, free, mg_set_request_handler(), mg_start(), mg_stop(), NULL, printf, and user_handler().
Referenced by main(), and TEST_CASE().
|
static |
HTTP request handler for user lookup.
Parses the request URI to extract the username, fetches the corresponding GitHub user, and responds with a JSON object.
conn | The connection to the client. |
cbdata | Callback data (unused). |
Definition at line 26 of file server.c.
References User::company, fetch_github_user(), mg_request_info::local_uri, User::location, User::login, mg_get_request_info(), mg_printf(), and User::name.
Referenced by start_http_server().