Modulo che gestisce le connessioni http in entrata/uscita.
Continua...
Modulo che gestisce le connessioni http in entrata/uscita.
◆ HttpCallback
typedef int(* HttpCallback) (int socket, void *data) |
Funzione di callback.
- Parametri
-
socket | File Descriptor del socket |
data | puntatore 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
◆ 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.
|
◆ 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
-
this | Istanza dell'HttpServer |
method | Metodo http di match |
url | Url di match |
callback | Funzione da chiamare in caso di match |
data | Puntatore 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
-
this | Istanza dell'HttpServer |
address | IP server (NULL = "0.0.0.0") |
port | Porta del server |
- Restituisce
- 0 se non ci sono stati errori
- Nota
- Funzione NON bloccante
◆ http_server_join()
Attende che il server sia terminato.
- Parametri
-
- Restituisce
- 0 se non ci sono stati errori
- Nota
- Funzione bloccante
◆ http_server_start()
Avvia il server.
- Parametri
-
- Restituisce
- 0 se non ci sono stati errori
- Nota
- Funzione NON bloccante
◆ http_server_stop()
Termina forzatamente il server.
- Parametri
-
- Restituisce
- 0 se non ci sono stati errori
- Nota
- Funzione NON bloccante