nanoev/tiny_httpd/Tiny_httpd_ws/index.html
2025-05-05 14:16:16 +00:00

18 lines
4.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Tiny_httpd_ws (tiny_httpd.Tiny_httpd_ws)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.0.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../index.html">Index</a> &#x00BB; <a href="../index.html">tiny_httpd</a> &#x00BB; Tiny_httpd_ws</nav><header class="odoc-preamble"><h1>Module <code><span>Tiny_httpd_ws</span></code></h1><p>Websockets for Tiny_httpd.</p><p>This sub-library (<code>tiny_httpd.ws</code>) exports a small implementation for a websocket server. It has no additional dependencies.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-handler"><a href="#type-handler" class="anchor"></a><code><span><span class="keyword">type</span> handler</span><span> =
<span><span>unit <a href="../Tiny_httpd_core/Request/index.html#type-t">Tiny_httpd_core.Request.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../Tiny_httpd_core/IO/Input/class-type-t/index.html">Tiny_httpd_core.IO.Input.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../Tiny_httpd_core/IO/Output/class-type-t/index.html">Tiny_httpd_core.IO.Output.t</a> <span class="arrow">&#45;&gt;</span></span>
unit</span></code></div><div class="spec-doc"><p>Websocket handler</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-upgrade"><a href="#val-upgrade" class="anchor"></a><code><span><span class="keyword">val</span> upgrade :
<span><a href="../Tiny_httpd_core/IO/Input/class-type-t/index.html">Tiny_httpd_core.IO.Input.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../Tiny_httpd_core/IO/Output/class-type-t/index.html">Tiny_httpd_core.IO.Output.t</a> <span class="arrow">&#45;&gt;</span></span>
<a href="../Tiny_httpd_core/IO/Input/class-type-t/index.html">Tiny_httpd_core.IO.Input.t</a> * <a href="../Tiny_httpd_core/IO/Output/class-type-t/index.html">Tiny_httpd_core.IO.Output.t</a></span></code></div><div class="spec-doc"><p>Upgrade a byte stream to the websocket framing protocol.</p></div></div><div class="odoc-spec"><div class="spec exception anchored" id="exception-Close_connection"><a href="#exception-Close_connection" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Close_connection</span></span></code></div><div class="spec-doc"><p>Exception that can be raised from IOs inside the handler, when the connection is closed from underneath.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_route_handler"><a href="#val-add_route_handler" class="anchor"></a><code><span><span class="keyword">val</span> add_route_handler :
<span><span class="optlabel">?accept</span>:<span>(<span><span>unit <a href="../Tiny_httpd_core/Request/index.html#type-t">Tiny_httpd_core.Request.t</a></span> <span class="arrow">&#45;&gt;</span></span> <span><span>(unit, int * string)</span> <a href="../../ocaml/Stdlib/index.html#type-result">result</a></span>)</span> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?accept_ws_protocol</span>:<span>(<span>string <span class="arrow">&#45;&gt;</span></span> bool)</span> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?middlewares</span>:<span><a href="../Tiny_httpd_core/Server/Head_middleware/index.html#type-t">Tiny_httpd_core.Server.Head_middleware.t</a> list</span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../Tiny_httpd_core/Server/index.html#type-t">Tiny_httpd_core.Server.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span><span>(<a href="../Tiny_httpd_core/Server/index.html#type-upgrade_handler">Tiny_httpd_core.Server.upgrade_handler</a>,
<a href="../Tiny_httpd_core/Server/index.html#type-upgrade_handler">Tiny_httpd_core.Server.upgrade_handler</a>)</span>
<a href="../Tiny_httpd_core/Route/index.html#type-t">Tiny_httpd_core.Route.t</a></span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-handler">handler</a> <span class="arrow">&#45;&gt;</span></span>
unit</span></code></div><div class="spec-doc"><p>Add a route handler for a websocket endpoint.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">accept_ws_protocol</span> <p>decides whether this endpoint accepts the websocket protocol sent by the client. Default accepts everything.</p></li></ul></div></div></div></body></html>