refactor: change project structure

This commit is contained in:
2025-10-26 17:51:41 +01:00
parent 33a12aaf73
commit 0293b0f5c0
25 changed files with 585 additions and 555 deletions

13
include/http/mime.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef CWS_MIME_H
#define CWS_MIME_H
#define ARR_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
typedef struct mimetype {
const char *ext;
const char *type;
} mimetype;
int http_get_content_type(char *location_path, char *content_type);
#endif

View File

@@ -5,11 +5,9 @@
#include <myclib/mystring.h>
#include <stddef.h>
#define ARR_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
#define CWS_HTTP_CONTENT_TYPE 64
#define CWS_HTTP_HEADER_MAX 512
#define CWS_HTTP_HEADER_CONTENT_MAX 1024
#define CWS_HTTP_CONTENT_TYPE 64
typedef enum cws_http_method {
HTTP_GET,
@@ -26,11 +24,6 @@ typedef enum cws_http_status {
HTTP_NOT_IMPLEMENTED,
} cws_http_status_e;
typedef struct mimetype {
const char *ext;
const char *type;
} mimetype;
typedef struct cws_http {
int sockfd;
cws_http_method_e method;

14
include/http/response.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef CWS_RESPONSE_H
#define CWS_RESPONSE_H
#include "http/request.h"
#include <sys/types.h>
size_t http_simple_html(char **response, cws_http_status_e status, char *title, char *description);
size_t http_response_builder(char **response, cws_http_status_e status, char *content_type,
char *body, size_t body_len_bytes);
void cws_http_send_response(cws_http_s *request, cws_http_status_e status);
#endif