HttpServer
Micro http library written in c [UNIX]
Http_Server

Modulo che gestisce le connessioni http in entrata/uscita. Continua...

Strutture dati

struct  HttpServer
 Struttura del server. Continua...
 

Definizioni

#define HTTP_MAX_HANDLERS   128
 Numero massimo di handlers.
 
#define HTTP_MAX_WORKERS   4
 Numero massimo di worker.
 

Ridefinizioni di tipo (typedef)

typedef int(* HttpCallback) (int socket, void *data)
 Funzione di callback. Continua...
 

Tipi enumerati (enum)

enum  HttpServerState { HTTP_SERVER_STOPPED , HTTP_SERVER_INITIALIZED , HTTP_SERVER_RUNNING , HTTP_SERVER_STOPPING }
 Stati del server. Continua...
 

Funzioni

int http_server_init (struct HttpServer *this, const char address[], uint16_t port)
 Inizializza la struttura Server. Continua...
 
int http_server_add_handler (struct HttpServer *this, enum http_method method, const char *url, HttpCallback callback, void *data)
 Aggiunge un handler al server. Continua...
 
int http_server_start (struct HttpServer *this)
 Avvia il server. Continua...
 
int http_server_stop (struct HttpServer *this)
 Termina forzatamente il server. Continua...
 
int http_server_join (struct HttpServer *this)
 Attende che il server sia terminato. Continua...
 

Descrizione dettagliata

Modulo che gestisce le connessioni http in entrata/uscita.

Documentazione delle ridefinizioni di tipo (typedef)

◆ HttpCallback

typedef int(* HttpCallback) (int socket, void *data)

Funzione di callback.

Parametri
socketFile Descriptor del socket
datapuntatore a memoria dati definita dall'utente
Restituisce
0 se non ci sono stati errori
Avvertimento
È possibile che i dati puntati da data vengano letti/modificati da più thread

Documentazione dei tipi enumerati

◆ HttpServerState

Stati del server.

Valori del tipo enumerato
HTTP_SERVER_STOPPED 

Server fermo.

HTTP_SERVER_INITIALIZED 

Server inizializzato.

HTTP_SERVER_RUNNING 

Server in esecuzione.

HTTP_SERVER_STOPPING 

Server in spegnimento.

Documentazione delle funzioni

◆ http_server_add_handler()

int http_server_add_handler ( struct HttpServer this,
enum http_method  method,
const char *  url,
HttpCallback  callback,
void *  data 
)

Aggiunge un handler al server.

Parametri
thisIstanza dell'HttpServer
methodMetodo http di match
urlUrl di match
callbackFunzione da chiamare in caso di match
dataPuntatore ad un'allocazione di memoria definita dall'utente (Questo puntatore verrà passato come parametro al callback)
Restituisce
0 se non ci sono stati errori
Nota
Funzione NON bloccante

◆ http_server_init()

int http_server_init ( struct HttpServer this,
const char  address[],
uint16_t  port 
)

Inizializza la struttura Server.

Parametri
thisIstanza dell'HttpServer
addressIP server (NULL = "0.0.0.0")
portPorta del server
Restituisce
0 se non ci sono stati errori
Nota
Funzione NON bloccante

◆ http_server_join()

int http_server_join ( struct HttpServer this)

Attende che il server sia terminato.

Parametri
thisIstanza dell'HttpServer
Restituisce
0 se non ci sono stati errori
Nota
Funzione bloccante

◆ http_server_start()

int http_server_start ( struct HttpServer this)

Avvia il server.

Parametri
thisIstanza dell'HttpServer
Restituisce
0 se non ci sono stati errori
Nota
Funzione NON bloccante

◆ http_server_stop()

int http_server_stop ( struct HttpServer this)

Termina forzatamente il server.

Parametri
thisIstanza dell'HttpServer
Restituisce
0 se non ci sono stati errori
Nota
Funzione NON bloccante