|
| tf_http_t * | tf_httpd_create (JSContext *context) |
| |
| void | tf_httpd_destroy (tf_http_t *http) |
| |
| const char * | tf_httpd_ext_to_content_type (const char *ext, bool use_fallback) |
| |
| const char * | tf_httpd_magic_bytes_to_content_type (const uint8_t *bytes, size_t size) |
| |
| tf_httpd_user_app_t * | tf_httpd_parse_user_app_from_path (const char *path, const char *expected_suffix) |
| |
| const char ** | tf_httpd_form_data_decode (const char *data, int length) |
| |
| const char * | tf_httpd_form_data_get (const char **form_data, const char *key) |
| |
| JSValue | tf_httpd_authenticate_jwt (tf_ssb_t *ssb, JSContext *context, const char *jwt) |
| |
| bool | tf_httpd_is_name_valid (const char *name) |
| |
| const char * | tf_httpd_make_set_session_cookie_header (tf_http_request_t *request, const char *session_cookie) |
| |
| const char * | tf_httpd_make_session_jwt (JSContext *context, tf_ssb_t *ssb, const char *name) |
| |
| void | tf_httpd_endpoint_static (tf_http_request_t *request) |
| |
| void | tf_httpd_endpoint_view (tf_http_request_t *request) |
| |
| void | tf_httpd_endpoint_save (tf_http_request_t *request) |
| |
| void | tf_httpd_endpoint_delete (tf_http_request_t *request) |
| |
| void | tf_httpd_endpoint_app (tf_http_request_t *request) |
| |
| void | tf_httpd_endpoint_app_index (tf_http_request_t *request) |
| |
| void | tf_httpd_endpoint_app_socket (tf_http_request_t *request) |
| |
| void | tf_httpd_endpoint_login (tf_http_request_t *request) |
| |
| void | tf_httpd_endpoint_login_auto (tf_http_request_t *request) |
| |
| void | tf_httpd_endpoint_logout (tf_http_request_t *request) |
| |
Exposes the HTTP Server server to script and registers a number of built-in endpoints.
◆ JSContext
◆ tf_http_request_t
◆ tf_http_t
◆ tf_httpd_user_app_t
◆ tf_ssb_t
◆ tf_httpd_authenticate_jwt()
| JSValue tf_httpd_authenticate_jwt |
( |
tf_ssb_t * |
ssb, |
|
|
JSContext * |
context, |
|
|
const char * |
jwt |
|
) |
| |
Validate a JWT.
- Parameters
-
| ssb | The SSB instance. |
| context | A JS context. |
| jwt | The JWT. |
- Returns
- The JWT contents if valid.
◆ tf_httpd_create()
Create the HTTP server instance.
- Parameters
-
◆ tf_httpd_destroy()
Destroy the HTTP server instance.
- Parameters
-
| http | The HTTP server instance. |
◆ tf_httpd_endpoint_app()
◆ tf_httpd_endpoint_app_index()
App index endpoint.
- Parameters
-
◆ tf_httpd_endpoint_app_socket()
App WebSocket.
- Parameters
-
◆ tf_httpd_endpoint_delete()
Delete a blob or app.
- Parameters
-
◆ tf_httpd_endpoint_login()
Login endpoint.
- Parameters
-
◆ tf_httpd_endpoint_login_auto()
Auto-login endpoint.
- Parameters
-
◆ tf_httpd_endpoint_logout()
Logout endpoint.
- Parameters
-
◆ tf_httpd_endpoint_save()
Save a blob or app.
- Parameters
-
◆ tf_httpd_endpoint_static()
Serve a static file.
- Parameters
-
◆ tf_httpd_endpoint_view()
◆ tf_httpd_ext_to_content_type()
| const char * tf_httpd_ext_to_content_type |
( |
const char * |
ext, |
|
|
bool |
use_fallback |
|
) |
| |
Determine a content-type from a file extension.
- Parameters
-
| ext | The file extension. |
| use_fallback | If not found, fallback to application/binary. |
- Returns
- A MIME type or NULL.
◆ tf_httpd_form_data_decode()
| const char ** tf_httpd_form_data_decode |
( |
const char * |
data, |
|
|
int |
length |
|
) |
| |
Decode form data into key value pairs.
- Parameters
-
| data | The form data string. |
| length | The length of the form data string. |
- Returns
- Key values pairs terminated by NULL.
◆ tf_httpd_form_data_get()
| const char * tf_httpd_form_data_get |
( |
const char ** |
form_data, |
|
|
const char * |
key |
|
) |
| |
Get a form data value from an array of key value pairs produced by tf_httpd_form_data_decode().
- Parameters
-
| form_data | The form data. |
| key | The key for which to fetch the value. |
- Returns
- the value for the case-insensitive key or NULL.
◆ tf_httpd_is_name_valid()
| bool tf_httpd_is_name_valid |
( |
const char * |
name | ) |
|
Check if a name meets requirements.
- Parameters
-
- Returns
- true if the name is valid.
◆ tf_httpd_magic_bytes_to_content_type()
| const char * tf_httpd_magic_bytes_to_content_type |
( |
const uint8_t * |
bytes, |
|
|
size_t |
size |
|
) |
| |
Determine a content type from magic bytes.
- Parameters
-
| bytes | The first bytes of a file. |
| size | The length of the bytes. |
- Returns
- A MIME type or NULL.
◆ tf_httpd_make_session_jwt()
| const char * tf_httpd_make_session_jwt |
( |
JSContext * |
context, |
|
|
tf_ssb_t * |
ssb, |
|
|
const char * |
name |
|
) |
| |
Make a JWT for the session.
- Parameters
-
| context | A JS context. |
| ssb | The SSB instance. |
| name | The username. |
- Returns
- The JWT.
◆ tf_httpd_make_set_session_cookie_header()
| const char * tf_httpd_make_set_session_cookie_header |
( |
tf_http_request_t * |
request, |
|
|
const char * |
session_cookie |
|
) |
| |
Make a header for the session cookie.
- Parameters
-
| request | The HTTP request. |
| session_cookie | The session cookie. |
- Returns
- The header.
◆ tf_httpd_parse_user_app_from_path()
| tf_httpd_user_app_t * tf_httpd_parse_user_app_from_path |
( |
const char * |
path, |
|
|
const char * |
expected_suffix |
|
) |
| |
Parse a username and app from a path like /~user/app/.
- Parameters
-
| path | The path. |
| expected_suffix | A suffix that is required to be on the path, and removed. |
- Returns
- The user and app. Free with tf_free().