diff options
| -rw-r--r-- | fw/src/http.c | 29 | 
1 files changed, 29 insertions, 0 deletions
diff --git a/fw/src/http.c b/fw/src/http.c index 36ad7c0..96a70fe 100644 --- a/fw/src/http.c +++ b/fw/src/http.c @@ -11,6 +11,7 @@  #include <zephyr/logging/log.h>  #include <zephyr/net/http/server.h>  #include <zephyr/net/http/service.h> +#include <zephyr/net/http/status.h>  LOG_MODULE_REGISTER(http); @@ -31,11 +32,39 @@ struct http_resource_detail_static index_resource_detail = {  	.static_data_len = sizeof(index_html_gz),  }; +static int favicon_handler( +	struct http_client_ctx *client, +	enum http_data_status status, +	const struct http_request_ctx *request_ctx, +	struct http_response_ctx *response_ctx, +	void *user_data +) { +	LOG_DBG("Handling favicon request"); + +	response_ctx->body = NULL; +	response_ctx->body_len = 0; +	response_ctx->final_chunk = true; +	response_ctx->status = HTTP_204_NO_CONTENT; + +	LOG_DBG("Favicon request handled"); +	return 0; +} + +static struct http_resource_detail_dynamic favicon_resource_detail = { +	.common = { +			.type = HTTP_RESOURCE_TYPE_DYNAMIC, +			.bitmask_of_supported_http_methods = BIT(HTTP_GET), +		}, +	.cb = favicon_handler, +	.user_data = NULL, +}; +  static uint16_t http_port = 80;  HTTP_SERVICE_DEFINE(http_service, NULL, &http_port, 1, 10, NULL, NULL);  HTTP_RESOURCE_DEFINE(index_resource, http_service, "/", &index_resource_detail); +HTTP_RESOURCE_DEFINE(favicon_resource, http_service, "/favicon.ico", &favicon_resource_detail);  int init_http_server(void) {  	LOG_DBG("Starting HTTP server");  | 
