Everywhere: Make session->send() callable
This commit is contained in:
parent
40b3fceab1
commit
c6f74cfa84
26 changed files with 87 additions and 48 deletions
|
@ -245,7 +245,7 @@ U0 @slon_admin_delete_account(SlonHttpSession* session)
|
|||
}
|
||||
}
|
||||
@slon_db_save_to_disk;
|
||||
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT);
|
||||
session->send(SLON_EMPTY_JSON_OBJECT);
|
||||
}
|
||||
|
||||
U0 @slon_admin_new_account(SlonHttpSession* session)
|
||||
|
@ -255,16 +255,16 @@ U0 @slon_admin_new_account(SlonHttpSession* session)
|
|||
if (db->o("actors")->@(request_json->@("username"))) {
|
||||
StrPrint(scratch_buffer, "{\"error\":\"account already exists\"}");
|
||||
@slon_http_set_content_type(session, "application/json");
|
||||
@slon_http_send(session, scratch_buffer, StrLen(scratch_buffer));
|
||||
session->send(scratch_buffer, StrLen(scratch_buffer));
|
||||
} else {
|
||||
@slon_admin_create_account(session);
|
||||
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT);
|
||||
session->send(SLON_EMPTY_JSON_OBJECT);
|
||||
}
|
||||
}
|
||||
|
||||
U0 @slon_admin_manage_accounts(SlonHttpSession* session)
|
||||
{
|
||||
@slon_http_send_json(session, db->a("accounts"));
|
||||
session->send(db->a("accounts"));
|
||||
}
|
||||
|
||||
U0 @slon_admin_info_stats(SlonHttpSession* session)
|
||||
|
@ -277,7 +277,7 @@ U0 @slon_admin_info_stats(SlonHttpSession* session)
|
|||
String.Append(scratch_buffer, "}");
|
||||
|
||||
@slon_http_set_content_type(session, "application/json");
|
||||
@slon_http_send(session, scratch_buffer, StrLen(scratch_buffer));
|
||||
session->send(scratch_buffer, StrLen(scratch_buffer));
|
||||
}
|
||||
|
||||
U0 @slon_admin_server_get(SlonHttpSession* session)
|
||||
|
@ -330,7 +330,7 @@ U0 @slon_admin_setup_instance(SlonHttpSession* session)
|
|||
@slon_db_save_to_disk;
|
||||
db->set("setup", TRUE);
|
||||
|
||||
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT);
|
||||
session->send(SLON_EMPTY_JSON_OBJECT);
|
||||
}
|
||||
|
||||
U0 @slon_admin_server_post(SlonHttpSession* session)
|
||||
|
|
|
@ -107,7 +107,7 @@ U0 @slon_local_server_directory_listing(SlonHttpSession* session, U8* path)
|
|||
String.Append(html, "</body></html>");
|
||||
|
||||
@slon_http_set_content_type(session, "text/html");
|
||||
@slon_http_send(session, html, StrLen(html));
|
||||
session->send(html, StrLen(html));
|
||||
@slon_free(session, html);
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ U0 @slon_local_server_not_found(SlonHttpSession* session)
|
|||
{
|
||||
session->status(404);
|
||||
@slon_http_set_content_type(session, "text/html");
|
||||
@slon_http_send(session, "<h2>404 Not Found</h2>", 22);
|
||||
session->send("<h2>404 Not Found</h2>", 22);
|
||||
}
|
||||
|
||||
U0 @slon_local_server_get(SlonHttpSession* session)
|
||||
|
|
|
@ -102,6 +102,27 @@ SlonHttpSession* @slon_http_init_session(TcpSocket* s)
|
|||
a += 0x31;
|
||||
@patch_call_rel32(a, &@slon_http_set_header);
|
||||
|
||||
// Create a copy of function and patch send
|
||||
code_size = MSize(&@slon_session_send_wrapper_function);
|
||||
session->send = CAlloc(code_size, adam_task->code_heap);
|
||||
MemCpy(session->send, &@slon_session_send_wrapper_function, code_size);
|
||||
|
||||
a = session->send;
|
||||
a += 0x16;
|
||||
MemSetI64(a, session, 1);
|
||||
|
||||
a = session->send;
|
||||
a += 0x33;
|
||||
@patch_call_rel32(a, &@slon_http_send_json);
|
||||
|
||||
a = session->send;
|
||||
a += 0x41;
|
||||
@patch_call_rel32(a, &@slon_http_send_string);
|
||||
|
||||
a = session->send;
|
||||
a += 0x4c;
|
||||
@patch_call_rel32(a, &@slon_http_send);
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
|
@ -409,7 +430,7 @@ U0 @slon_http_handle_delete_request(SlonHttpSession* session)
|
|||
/* clang-format on */
|
||||
|
||||
// FIXME: Implement this
|
||||
@slon_http_send_json(session, SLON_EMPTY_JSON_OBJECT);
|
||||
session->send(SLON_EMPTY_JSON_OBJECT);
|
||||
}
|
||||
|
||||
U0 @slon_http_handle_get_request(SlonHttpSession* session)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue