mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-27 22:17:32 +01:00
20 lines
8.4 KiB
HTML
20 lines
8.4 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../"><link rel="stylesheet" href="dmdoc.css"><title>/datum/http_request - Space Station 13</title></head><body><header><a href="index.html">Space Station 13</a> - <a href="index.html#modules">Modules</a> - <a href="index.html#types">Types</a> — <a href="datum/http_request.html#var">Var Details</a> - <a href="datum/http_request.html#proc">Proc Details</a></header><main><h1>HTTP Request <aside>/<a href="datum.html">datum</a>/<a href="datum/http_request.html">http_request</a></aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L14"><img src="git.png" width="16" height="16" title="code/datums/http.dm 14"></a></h1><p>Holder datum for ingame HTTP requests</p>
|
||
<p>Holds information regarding to methods used, URL, and response,
|
||
as well as job IDs and progress tracking for async requests</p><table class="summary" cellspacing="0"><tr><td colspan="2"><h2>Vars</h2></td></tr><tr><th><a href="datum/http_request.html#var/body">body</a></th><td>Body of the request being sent</td></tr><tr><th><a href="datum/http_request.html#var/cb">cb</a></th><td>Callback for executing after async requests. Will be called with an argument of <a href="datum/http_response.html" title="/datum/http_response">/datum/http_response</a> as first argument</td></tr><tr><th><a href="datum/http_request.html#var/error_code">error_code</a></th><td>Job error code, if any</td></tr><tr><th><a href="datum/http_request.html#var/headers">headers</a></th><td>Request headers being sent</td></tr><tr><th><a href="datum/http_request.html#var/id">id</a></th><td>The ID of the request (Only set if it is an async request)</td></tr><tr><th><a href="datum/http_request.html#var/in_progress">in_progress</a></th><td>Is the request in progress? (Only set if it is an async request)</td></tr><tr><th><a href="datum/http_request.html#var/method">method</a></th><td>HTTP method used</td></tr><tr><th><a href="datum/http_request.html#var/response_obj">response_obj</a></th><td>The response for the request</td></tr><tr><th><a href="datum/http_request.html#var/url">url</a></th><td>URL that the request is being sent to</td></tr><tr><td colspan="2"><h2>Procs</h2></td></tr><tr><th><a href="datum/http_request.html#proc/begin_async">begin_async</a></th><td>Async execution starter</td></tr><tr><th><a href="datum/http_request.html#proc/into_response">into_response</a></th><td>Response deserializer</td></tr><tr><th><a href="datum/http_request.html#proc/is_complete">is_complete</a></th><td>Async completion checker</td></tr><tr><th><a href="datum/http_request.html#proc/prepare">prepare</a></th><td>Preparation handler</td></tr></table><h2 id="var">Var Details</h2><h3 id="var/body"><aside class="declaration">var </aside>body <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L22"><img src="git.png" width="16" height="16" title="code/datums/http.dm 22"></a></h3><p>Body of the request being sent</p><h3 id="var/cb"><aside class="declaration">var </aside>cb <aside>– /<a href="datum.html">datum</a>/callback</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L32"><img src="git.png" width="16" height="16" title="code/datums/http.dm 32"></a></h3><p>Callback for executing after async requests. Will be called with an argument of <a href="datum/http_response.html" title="/datum/http_response">/datum/http_response</a> as first argument</p><h3 id="var/error_code"><aside class="declaration">var </aside>error_code <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L28"><img src="git.png" width="16" height="16" title="code/datums/http.dm 28"></a></h3><p>Job error code, if any</p><h3 id="var/headers"><aside class="declaration">var </aside>headers <aside>– /list</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L24"><img src="git.png" width="16" height="16" title="code/datums/http.dm 24"></a></h3><p>Request headers being sent</p><h3 id="var/id"><aside class="declaration">var </aside>id <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L16"><img src="git.png" width="16" height="16" title="code/datums/http.dm 16"></a></h3><p>The ID of the request (Only set if it is an async request)</p><h3 id="var/in_progress"><aside class="declaration">var </aside>in_progress <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L18"><img src="git.png" width="16" height="16" title="code/datums/http.dm 18"></a></h3><p>Is the request in progress? (Only set if it is an async request)</p><h3 id="var/method"><aside class="declaration">var </aside>method <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L20"><img src="git.png" width="16" height="16" title="code/datums/http.dm 20"></a></h3><p>HTTP method used</p><h3 id="var/response_obj"><aside class="declaration">var </aside>response_obj <aside>– /<a href="datum.html">datum</a>/<a href="datum/http_response.html">http_response</a></aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L30"><img src="git.png" width="16" height="16" title="code/datums/http.dm 30"></a></h3><p>The response for the request</p><h3 id="var/url"><aside class="declaration">var </aside>url <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L26"><img src="git.png" width="16" height="16" title="code/datums/http.dm 26"></a></h3><p>URL that the request is being sent to</p><h2 id="proc">Proc Details</h2><h3 id="proc/begin_async"><aside class="declaration">proc </aside>begin_async<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L67"><img src="git.png" width="16" height="16" title="code/datums/http.dm 67"></a></aside></h3><p>Async execution starter</p>
|
||
<p>Tells the request to start executing inside its own thread inside RUSTG
|
||
Preferred over blocking, but also requires SShttp to be active
|
||
As such, you cannot use this for events which may happen at roundstart (EG: IPIntel, BYOND account tracking, etc)</p><h3 id="proc/into_response"><aside class="declaration">proc </aside>into_response<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L104"><img src="git.png" width="16" height="16" title="code/datums/http.dm 104"></a></aside></h3><p>Response deserializer</p>
|
||
<p>Takes a HTTP request object, and converts it into a <a href="datum/http_response.html" title="/datum/http_response">/datum/http_response</a>
|
||
The entire thing is wrapped in try/catch to ensure it doesnt break on invalid requests
|
||
Can be called on async and blocking requests</p><h3 id="proc/is_complete"><aside class="declaration">proc </aside>is_complete<aside>() <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L77"><img src="git.png" width="16" height="16" title="code/datums/http.dm 77"></a></aside></h3><p>Async completion checker</p>
|
||
<p>Checks if an async request has been complete
|
||
Has safety checks built in to compensate if you call this on blocking requests,
|
||
or async requests which have already finished</p><h3 id="proc/prepare"><aside class="declaration">proc </aside>prepare<aside>(_method, _url, _body, /list/_headers) <a href="https://github.com/ParadiseSS13/Paradise/blob/776b9861f70566b1e6a0763a465ef22f7920a3d6/code/datums/http.dm#L52"><img src="git.png" width="16" height="16" title="code/datums/http.dm 52"></a></aside></h3><p>Preparation handler</p>
|
||
<p>Call this with relevant parameters to form the request you want to make</p>
|
||
<p>Arguments:</p>
|
||
<ul>
|
||
<li>_method - HTTP Method to use, see code/__DEFINES/rust.dm for a full list</li>
|
||
<li>_url - The URL to send the request to</li>
|
||
<li>_body - The body of the request, if applicable</li>
|
||
<li>_headers - Associative list of HTTP headers to send, if applicab;e</li>
|
||
</ul></main><footer>paradise.dme <a href="https://github.com/ParadiseSS13/Paradise/tree/776b9861f70566b1e6a0763a465ef22f7920a3d6">776b986</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.11.0</a></footer></body></html> |