Everywhere: Use session->path()

This commit is contained in:
Alec Murphy 2025-02-21 18:10:25 -05:00
parent ff5a07dc04
commit 66074a5472
31 changed files with 48 additions and 48 deletions

View file

@ -5,7 +5,7 @@ U0 @slon_api_v1_notifications_get(SlonHttpSession* session)
if (@slon_api_authorized(session)) {
// SLON_AUTH_ACCOUNT_ID
// FIXME: Implement this
if (String.EndsWith("policy", @slon_http_request_path(session))) {
if (String.EndsWith("policy", session->path())) {
session->send(SLON_EMPTY_JSON_OBJECT);
} else {
session->send(SLON_EMPTY_JSON_ARRAY);

View file

@ -1,4 +1,4 @@
if (String.BeginsWith("/api/v1/statuses", @slon_http_request_path(session))) {
if (String.BeginsWith("/api/v1/statuses", session->path())) {
@slon_api_v1_statuses_delete(session);
return;
}

View file

@ -1,4 +1,4 @@
if (String.BeginsWith("/api/v1/accounts", @slon_http_request_path(session))) {
if (String.BeginsWith("/api/v1/accounts", session->path())) {
@slon_api_v1_accounts_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (String.BeginsWith("/users/", @slon_http_request_path(session)) && String.EndsWith("json", session->header("accept"))) {
if (String.BeginsWith("/users/", session->path()) && String.EndsWith("json", session->header("accept"))) {
@slon_activitypub_users_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v1/blocks", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/blocks", session->path())) {
@slon_api_v1_blocks_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v1/bookmarks", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/bookmarks", session->path())) {
@slon_api_v1_bookmarks_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v1/conversations", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/conversations", session->path())) {
@slon_api_v1_conversations_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v1/custom_emojis", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/custom_emojis", session->path())) {
@slon_api_v1_custom_emojis_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v1/favourites", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/favourites", session->path())) {
@slon_api_v1_favourites_get(session);
return;
}

View file

@ -1,9 +1,9 @@
if (!StrICmp("/api/v1/filters", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/filters", session->path())) {
@slon_api_v1_filters_get(session);
return;
}
if (!StrICmp("/api/v2/filters", @slon_http_request_path(session))) {
if (!StrICmp("/api/v2/filters", session->path())) {
@slon_api_v2_filters_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v1/follow_requests", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/follow_requests", session->path())) {
@slon_api_v1_follow_requests_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v1/followed_tags", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/followed_tags", session->path())) {
@slon_api_v1_followed_tags_get(session);
return;
}

View file

@ -1,9 +1,9 @@
if (!StrICmp("/api/v1/instance", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/instance", session->path())) {
session->send(db->o("instance"));
return;
}
if (!StrICmp("/api/v2/instance", @slon_http_request_path(session))) {
if (!StrICmp("/api/v2/instance", session->path())) {
@slon_api_v2_instance_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/nodeinfo/2.0", @slon_http_request_path(session))) {
if (!StrICmp("/nodeinfo/2.0", session->path())) {
@slon_nodeinfo_20(session);
return;
}

View file

@ -1,4 +1,4 @@
if (String.BeginsWith("/api/v1/notifications", @slon_http_request_path(session))) {
if (String.BeginsWith("/api/v1/notifications", session->path())) {
@slon_api_v1_notifications_get(session);
return;
}

View file

@ -1,9 +1,9 @@
if (!StrICmp("/oauth/authorize", @slon_http_request_path(session))) {
if (!StrICmp("/oauth/authorize", session->path())) {
@slon_http_send_html_file(session, "M:/Slon/Static/oauth/authorize.html");
return;
}
if (!StrICmp("/oauth/verify_access", @slon_http_request_path(session))) {
if (!StrICmp("/oauth/verify_access", session->path())) {
@slon_oauth_verify_access_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v2/search", @slon_http_request_path(session))) {
if (!StrICmp("/api/v2/search", session->path())) {
@slon_api_v2_search_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v2/suggestions", @slon_http_request_path(session))) {
if (!StrICmp("/api/v2/suggestions", session->path())) {
@slon_api_v2_suggestions_get(session);
return;
}

View file

@ -1,4 +1,4 @@
if (String.BeginsWith("/api/v1/timelines", @slon_http_request_path(session))) {
if (String.BeginsWith("/api/v1/timelines", session->path())) {
@slon_api_v1_timelines_get(session);
return;
}

View file

@ -1,28 +1,28 @@
if (String.EndsWith(".css", @slon_http_request_path(session))) {
if (String.EndsWith(".css", session->path())) {
session->content_type("text/css");
@slon_http_send_file(session, "M:/Slon/Static/css/main.css");
return;
}
if (!StrICmp("/js/header.js", @slon_http_request_path(session))) {
if (!StrICmp("/js/header.js", session->path())) {
session->content_type("text/javascript");
@slon_http_send_file(session, "M:/Slon/Static/js/header.js");
return;
}
if (String.EndsWith(".js", @slon_http_request_path(session))) {
if (String.EndsWith(".js", session->path())) {
session->content_type("text/javascript");
@slon_http_send_file(session, "M:/Slon/Static/js/statuses.js");
return;
}
if (!StrICmp("/alec.png", @slon_http_request_path(session))) {
if (!StrICmp("/alec.png", session->path())) {
session->content_type("image/png");
@slon_http_send_file(session, "A:/avatar-circle-4bpp.png");
return;
}
if (String.BeginsWith("/@", @slon_http_request_path(session))) {
if (String.BeginsWith("/@", session->path())) {
@slon_web_user_get(session);
return;
}

View file

@ -1,19 +1,19 @@
if (!StrICmp("/.well-known/host-meta", @slon_http_request_path(session))) {
if (!StrICmp("/.well-known/host-meta", session->path())) {
@slon_host_meta(session);
return;
}
if (!StrICmp("/.well-known/nodeinfo", @slon_http_request_path(session))) {
if (!StrICmp("/.well-known/nodeinfo", session->path())) {
@slon_nodeinfo(session);
return;
}
if (!StrICmp("/.well-known/oauth-authorization-server", @slon_http_request_path(session))) {
if (!StrICmp("/.well-known/oauth-authorization-server", session->path())) {
@slon_oauth_well_known(session);
return;
}
if (!StrICmp("/.well-known/webfinger", @slon_http_request_path(session))) {
if (!StrICmp("/.well-known/webfinger", session->path())) {
@slon_webfinger(session);
return;
}

View file

@ -1,4 +1,4 @@
if (String.BeginsWith("/api/v1/accounts", @slon_http_request_path(session))) {
if (String.BeginsWith("/api/v1/accounts", session->path())) {
@slon_api_v1_accounts_patch(session);
return;
}

View file

@ -1,4 +1,4 @@
if (String.BeginsWith("/api/v1/accounts", @slon_http_request_path(session))) {
if (String.BeginsWith("/api/v1/accounts", session->path())) {
@slon_api_v1_accounts_post(session);
return;
}

View file

@ -1,4 +1,4 @@
if (String.BeginsWith("/users/", @slon_http_request_path(session))) {
if (String.BeginsWith("/users/", session->path())) {
@slon_activitypub_users_post(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v1/apps", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/apps", session->path())) {
@slon_api_v1_apps_post(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/oauth/token", @slon_http_request_path(session))) {
if (!StrICmp("/oauth/token", session->path())) {
@slon_oauth_token_post(session);
return;
}

View file

@ -1,4 +1,4 @@
if (!StrICmp("/api/v1/statuses", @slon_http_request_path(session))) {
if (!StrICmp("/api/v1/statuses", session->path())) {
@slon_api_v1_statuses_post(session);
return;
}

View file

@ -283,7 +283,7 @@ U0 @slon_admin_info_stats(SlonHttpSession* session)
U0 @slon_admin_server_get(SlonHttpSession* session)
{
if (!db->@("setup")) {
if (StrICmp("/", @slon_http_request_path(session))) {
if (StrICmp("/", session->path())) {
session->status(302);
session->header("Location", "/");
} else {
@ -292,22 +292,22 @@ U0 @slon_admin_server_get(SlonHttpSession* session)
return;
}
if (!StrICmp("/info/stats", @slon_http_request_path(session))) {
if (!StrICmp("/info/stats", session->path())) {
@slon_admin_info_stats(session);
return;
}
if (!StrICmp("/delete/account", @slon_http_request_path(session))) {
if (!StrICmp("/delete/account", session->path())) {
@slon_admin_delete_account(session);
return;
}
if (!StrICmp("/manage/accounts", @slon_http_request_path(session))) {
if (!StrICmp("/manage/accounts", session->path())) {
@slon_admin_manage_accounts(session);
return;
}
if (!StrICmp("/", @slon_http_request_path(session))) {
if (!StrICmp("/", session->path())) {
@slon_http_send_html_file(session, "M:/Slon/Static/html/admin/main.html");
return;
}
@ -339,12 +339,12 @@ U0 @slon_admin_server_post(SlonHttpSession* session)
@slon_http_parse_request_as_json(session);
}
if (!StrICmp("/setup/instance", @slon_http_request_path(session))) {
if (!StrICmp("/setup/instance", session->path())) {
@slon_admin_setup_instance(session);
return;
}
if (!StrICmp("/new/account", @slon_http_request_path(session))) {
if (!StrICmp("/new/account", session->path())) {
@slon_admin_new_account(session);
return;
}

View file

@ -123,7 +123,7 @@ U0 @slon_local_server_get(SlonHttpSession* session)
SLON_SCRATCH_BUFFER_AND_REQUEST_JSON
no_warn request_json;
U8* path = @slon_http_request_path(session);
U8* path = session->path();
if (!path || !StrLen(path) || StrFind(":", path) > 0) {
@slon_local_server_not_found(session);

View file

@ -196,7 +196,7 @@ Bool @slon_activitypub_http_signature_is_valid(SlonHttpSession* session)
++i;
}
sig_string_alloc_length += StrLen(session->verb(1));
sig_string_alloc_length += StrLen(@slon_http_request_path(session));
sig_string_alloc_length += StrLen(session->path());
sig_string_alloc_length *= 2;
// Construct our signature string
@ -207,7 +207,7 @@ Bool @slon_activitypub_http_signature_is_valid(SlonHttpSession* session)
headers_split[i][0] += 'a' - headers_split[i][0];
}
if (!StrCmp("(request-target)", headers_split[i])) {
String.Append(sig_string, "(request-target): %s %s", "post", @slon_http_request_path(session));
String.Append(sig_string, "(request-target): %s %s", "post", session->path());
} else {
String.Append(sig_string, "%s: %s", headers_split[i], session->header(headers_split[i]));
}

View file

@ -4,7 +4,7 @@ U0 @slon_web_user_get(SlonHttpSession* session)
no_warn scratch_buffer, request_json;
I64 path_segments_count = 0;
U8** path_segments = String.Split(StrFind("@", @slon_http_request_path(session)) + 1, '/', &path_segments_count);
U8** path_segments = String.Split(StrFind("@", session->path()) + 1, '/', &path_segments_count);
U8* user = path_segments[0];