Hi there! I'm Sophie, and welcome to my own little place on the internet.
I'm a self-thought programmer who likes to travel and learn new stuff. I enjoy listening to music, being outside in nature, and having a chat with a good cup of coffee.
I'm currently working as an SAP E-Commerce Consultant at innovate Software GmbH. My expertise lies in developing custom-tailored software solutions for the SAP Commerce ecosystem.
You can get in touch with me via E-mail: info@soophie.de
API Reference
include
macro
macro HTTP_RESP_HANDLED
macro HTTP_RESP_HANDLEDHandled {http_resp_t}
#define HTTP_RESP_HANDLED (http_resp_t) { .status = __HTTP_STATUS_HANDLED }
macro HTTP_GET
macro HTTP_GET#define HTTP_GET(path, fn_name) _HTTP_ON("GET", path, fn_name)
macro HTTP_GET
macro HTTP_GET#define HTTP_HEAD(path, fn_name) _HTTP_ON("HEAD", path, fn_name)
macro HTTP_POST
macro HTTP_POST#define HTTP_POST(path, fn_name) _HTTP_ON("POST", path, fn_name)
macro HTTP_PUT
macro HTTP_PUT#define HTTP_PUT(path, fn_name) _HTTP_ON("PUT", path, fn_name)
macro HTTP_DELETE
macro HTTP_DELETE#define HTTP_DELETE(path, fn_name) _HTTP_ON("DELETE", path, fn_name)
macro HTTP_CONNECT
macro HTTP_CONNECT#define HTTP_CONNECT(path, fn_name) _HTTP_ON("CONNECT", path, fn_name)
macro HTTP_OPTIONS
macro HTTP_OPTIONS#define HTTP_OPTIONS(path, fn_name) _HTTP_ON("OPTIONS", path, fn_name)
macro HTTP_TRACE
macro HTTP_TRACE#define HTTP_TRACE(path, fn_name) _HTTP_ON("TRACE", path, fn_name)
macro HTTP_PATCH
macro HTTP_PATCH#define HTTP_PATCH(path, fn_name) _HTTP_ON("PATCH", path, fn_name)
macro HTTP_DEFAULT
macro HTTP_DEFAULT#define HTTP_DEFAULT(fn_name) \
static http_resp_t fn_name(http_req_t *req); \
__attribute__((constructor)) \
static void __macro_http_fn_register_##fn_name() { \
http_on_default(&fn_name); \
} \
static http_resp_t fn_name(http_req_t *req)
macro HTTP_MIDDLEWARE_PRE
macro HTTP_MIDDLEWARE_PRE#define HTTP_MIDDLEWARE_PRE(fn_name) \
static void fn_name(http_req_t *req); \
__attribute__((constructor)) \
static void __macro_http_fn_register_##fn_name() { \
http_on_pre_route(&fn_name); \
} \
static void fn_name(http_req_t *req)
macro HTTP_MIDDLEWARE_POST
macro HTTP_MIDDLEWARE_POST#define HTTP_MIDDLEWARE_POST(fn_name) \
static void fn_name(http_req_t *req); \
__attribute__((constructor)) \
static void __macro_http_fn_register_##fn_name() { \
http_on_post_route(&fn_name); \
} \
static void fn_name(http_req_t *req)
const
enum
enum http_err_t
enum http_err_tError code
typedef enum {
HTTP_ERR_OK = SOCK_ERR_OK,
HTTP_ERR_X = SOCK_ERR__COUNT + 1,
HTTP_ERR_Y = SOCK_ERR__COUNT + 2,
HTTP_ERR__COUNT
} http_err_t;
enum http_status_t
enum http_status_tHTTP status code
typedef enum {
HTTP_STATUS_CONTINUE = 100,
HTTP_STATUS_SWITCHING_PROTOCOLS = 101,
HTTP_STATUS_PROCESSING = 102,
HTTP_STATUS_EARLY_HINTS = 103,
HTTP_STATUS_OK = 200,
HTTP_STATUS_CREATED = 201,
HTTP_STATUS_ACCEPTED = 202,
HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203,
HTTP_STATUS_NO_CONTENT = 204,
HTTP_STATUS_RESET_CONTENT = 205,
HTTP_STATUS_PARTIAL_CONTENT = 206,
HTTP_STATUS_MULTI_STATUS = 207,
HTTP_STATUS_ALREADY_REPORTED = 208,
HTTP_STATUS_IM_USED = 226,
HTTP_STATUS_MULTIPLE_CHOICES = 300,
HTTP_STATUS_MOVED_PERMANENTLY = 301,
HTTP_STATUS_FOUND = 302,
HTTP_STATUS_SEE_OTHER = 303,
HTTP_STATUS_NOT_MODIFIED = 304,
HTTP_STATUS_TEMPORARY_REDIRECT = 307,
HTTP_STATUS_PERMANENT_REDIRECT = 308,
HTTP_STATUS_BAD_REQUEST = 400,
HTTP_STATUS_UNAUTHORIZED = 401,
HTTP_STATUS_PAYMENT_REQUIRED = 402,
HTTP_STATUS_FORBIDDEN = 403,
HTTP_STATUS_NOT_FOUND = 404,
HTTP_STATUS_METHOD_NOT_ALLOWED = 405,
HTTP_STATUS_NOT_ACCEPTABLE = 406,
HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407,
HTTP_STATUS_REQUEST_TIMEOUT = 408,
HTTP_STATUS_CONFLICT = 409,
HTTP_STATUS_GONE = 410,
HTTP_STATUS_LENGTH_REQUIRED = 411,
HTTP_STATUS_PRECONDITION_FAILED = 412,
HTTP_STATUS_PAYLOAD_TOO_LARGE = 413,
HTTP_STATUS_URI_TOO_LONG = 414,
HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415,
HTTP_STATUS_RANGE_NOT_SATISFIABLE = 416,
HTTP_STATUS_EXPECTATION_FAILED = 417,
HTTP_STATUS_I_AM_A_TEAPOT = 418,
HTTP_STATUS_MISDIRECTED_REQUEST = 421,
HTTP_STATUS_UNPROCESSABLE_CONTENT = 422,
HTTP_STATUS_LOCKED = 423,
HTTP_STATUS_FAILED_DEPENDENCY = 424,
HTTP_STATUS_TOO_EARLY = 425,
HTTP_STATUS_UPGRADE_REQUIRED = 426,
HTTP_STATUS_PRECONDITION_REQUIRED = 428,
HTTP_STATUS_TOO_MANY_REQUESTS = 429,
HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS = 451,
HTTP_STATUS_INTERNAL_SERVER_ERROR = 500,
HTTP_STATUS_NOT_IMPLEMENTED = 501,
HTTP_STATUS_BAD_GATEWAY = 502,
HTTP_STATUS_SERVICE_UNAVAILABLE = 503,
HTTP_STATUS_GATEWAY_TIMEOUT = 504,
HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED = 505,
HTTP_STATUS_VARIANT_ALSO_NEGOTITATES = 506,
HTTP_STATUS_INSUFFICIENT_STORAGE = 507,
HTTP_STATUS_LOOP_DETECTED = 508,
HTTP_STATUS_NOT_EXTENDED = 510,
HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511,
__HTTP_STATUS_HANDLED = 999,
} http_status_t;
struct
struct http_t
struct http_ttypedef struct http http_t;
struct http_host_t
struct http_host_ttypedef sock_host_t http_host_t;
struct http_bind_t
struct http_bind_ttypedef sock_bind_t http_bind_t;
struct http_conn_t
struct http_conn_ttypedef sock_conn_t http_conn_t;
struct http_header_t
struct http_header_tA HTTP header
typedef struct {
char *key;
char *value;
} http_header_t;
struct http_req_t
struct http_req_tA HTTP request struct
typedef struct {
http_conn_t *conn;
char *method;
char *url;
char *version;
http_header_t *headers;
int headers_len;
char *body;
long body_len;
void *ext_data;
} http_req_t;
struct http_resp_t
struct http_resp_tA HTTP response struct
typedef struct {
char *version;
http_status_t status;
http_header_t *headers;
int headers_len;
char *body;
long body_len;
} http_resp_t;
struct http_global_fn_t
struct http_global_fn_ttypedef http_resp_t (*http_global_fn_t)(http_t *, http_req_t *);
struct http_handle_fn_t
struct http_handle_fn_ttypedef http_resp_t (*http_handle_fn_t)(http_req_t *);
struct http_hook_fn_t
struct http_hook_fn_ttypedef void (*http_hook_fn_t)(http_req_t *);
struct http_route_t
struct http_route_ttypedef struct {
char *method;
char *path;
http_handle_fn_t fn;
} http_route_t;
struct http_pair_t
struct http_pair_ttypedef struct {
char *key;
char *value;
} http_pair_t;
struct http_pairs_t
struct http_pairs_ttypedef struct {
http_pair_t *pairs;
size_t len;
} http_pairs_t;
struct http
struct httpstruct http {
sock_t *sock;
http_global_fn_t fn;
};
union
func
func http_init
func http_initInits this and that and of course especiall that thing that no one cares about, you know what, don't pretend you do not.
http_t *http_init(void);
func http_cleanup
func http_cleanupCleans up
void http_cleanup(http_t *self);
func http_on_global
func http_on_globalvoid http_on_global(http_t *self, http_global_fn_t fn);
func http_on_route
func http_on_routevoid http_on_route(char *method, char *url, http_handle_fn_t fn);
func http_on_default
func http_on_defaultvoid http_on_default(http_handle_fn_t fn);
func http_on_pre_route
func http_on_pre_routevoid http_on_pre_route(http_hook_fn_t fn);
func http_on_post_route
func http_on_post_routevoid http_on_post_route(http_hook_fn_t fn);
func http_req_path
func http_req_pathchar *http_req_path(http_req_t *req);
func http_req_body
func http_req_bodychar *http_req_body(http_req_t *req);
func http_req_queries
func http_req_querieshttp_pairs_t http_req_queries(http_req_t *req);
func http_req_params
func http_req_paramshttp_pairs_t http_req_params(http_req_t *req);
func http_pairs_get
func http_pairs_getchar *http_pairs_get(http_pairs_t *self, char *key);
func http_pairs_has
func http_pairs_hasbool http_pairs_has(http_pairs_t *self, char *key);
func http_pairs_free
func http_pairs_freevoid http_pairs_free(http_pairs_t *self);
func http_req_header
func http_req_headerchar *http_req_header(http_req_t *req, char *key);
func http_resp_header
func http_resp_headervoid http_resp_header(http_resp_t *resp, char *key, char *value);
func http_resp_create
func http_resp_createhttp_resp_t http_resp_create(http_status_t status);
func http_resp_body
func http_resp_bodyvoid http_resp_body(http_resp_t *resp, char *body, long len);
func http_req_free
func http_req_freevoid http_req_free(http_req_t *req);
func http_resp_write_head
func http_resp_write_headvoid http_resp_write_head(http_conn_t *conn, http_resp_t *resp);
func http_resp_write_body
func http_resp_write_bodyvoid http_resp_write_body(http_conn_t *conn, http_resp_t *resp);
func http_resp_write
func http_resp_writevoid http_resp_write(http_conn_t *conn, http_resp_t *resp);
func http_resp_free
func http_resp_freevoid http_resp_free(http_resp_t *resp);
func http_bind
func http_bindhttp_err_t http_bind(http_t *self, char *hostname, int port, http_host_t *hosts, int hosts_len);
func http_listen
func http_listenhttp_err_t http_listen(http_t *self);
func http_bind_listen
func http_bind_listenhttp_err_t http_bind_listen(http_t *self, char *hostname, int port);
func http_close
func http_closevoid http_close(http_t *self);