<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Documentation on Syaiful Bahri</title><link>https://www.sbahri.com/docs/</link><description>Recent content in Documentation on Syaiful Bahri</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 28 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sbahri.com/docs/feed.xml" rel="self" type="application/rss+xml"/><item><title>Getting started</title><link>https://www.sbahri.com/docs/tapak/getting-started/</link><pubDate>Fri, 28 Aug 2026 00:00:00 +0000</pubDate><guid>https://www.sbahri.com/docs/tapak/getting-started/</guid><description>&lt;p&gt;Tapak is not on Opam yet (soon!). Until then, install it by pinning the Git
repository or by using Nix.&lt;/p&gt;
&lt;h3 id="install-with-opam"&gt;Install with Opam&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;# Tapak use cows for websocket
opam pin add cows https://github.com/syaiful6/cows.git
opam pin add tapak https://github.com/syaiful6/tapak.git

# Install dependencies and build
opam install cows tapak --deps-only
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Instead of pinning manually, add this to your Opam file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pin-depends: [
 [&amp;quot;cows&amp;quot;, &amp;quot;git+https://github.com/syaiful6/cows.git&amp;quot;]
 [&amp;quot;tapak&amp;quot;, &amp;quot;git+https://github.com/syaiful6/tapak.git&amp;quot;]
]
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="install-with-nix"&gt;Install with Nix&lt;/h3&gt;
&lt;p&gt;Add Tapak as flake input in your &lt;code&gt;flake.nix&lt;/code&gt;:&lt;/p&gt;</description></item><item><title>Routing</title><link>https://www.sbahri.com/docs/tapak/router/</link><pubDate>Fri, 28 Aug 2026 00:00:00 +0000</pubDate><guid>https://www.sbahri.com/docs/tapak/router/</guid><description>&lt;p&gt;Routes define your application&amp;rsquo;s endpoints. A Tapak handler usually does not
receive &lt;code&gt;Tapak.Request.t&lt;/code&gt; directly; it receives values extracted from the
request and returns &lt;code&gt;Tapak.Response.t&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Tapak&amp;rsquo;s router is type-safe, so the route definition determines the arguments
that its handler must accept.&lt;/p&gt;
&lt;h2 id="basic-routing"&gt;Basic routing&lt;/h2&gt;
&lt;pre&gt;&lt;code class="language-ocaml"&gt;(** All handlers below have type [unit -&amp;gt; Tapak.Response.t]. *)
let routes = Tapak.Router.(
 of_list
 [ get (s &amp;quot;&amp;quot;) |&amp;gt; unit |&amp;gt; into home_handler
 ; post (s &amp;quot;&amp;quot;) |&amp;gt; unit |&amp;gt; into home_post_handler
 ; put (s &amp;quot;&amp;quot;) |&amp;gt; unit |&amp;gt; into home_put_handler
 ; delete (s &amp;quot;&amp;quot;) |&amp;gt; unit |&amp;gt; into home_delete_handler
 ; patch (s &amp;quot;&amp;quot;) |&amp;gt; unit |&amp;gt; into home_patch_handler
 ]
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The router also provides &lt;code&gt;head&lt;/code&gt; and &lt;code&gt;any&lt;/code&gt;. Use &lt;code&gt;unit&lt;/code&gt; when a handler does not
need any values from the request. &lt;code&gt;of_list&lt;/code&gt; turns a list of routes into a
handler and accepts an optional &lt;code&gt;not_found&lt;/code&gt; handler.&lt;/p&gt;</description></item></channel></rss>