Skip to content

Commit

Permalink
Updated generated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Oct 30, 2020
1 parent 4631ec9 commit bec407e
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 1 deletion.
75 changes: 75 additions & 0 deletions docs/packages/http/router_utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@
<td class="code"><pre><code><div class="keyword">package</div> <div class="ident">httputils</div><div class="operator"></div>

<div class="keyword">import</div> <div class="operator">(</div>
<div class="literal">&#34;encoding/json&#34;</div><div class="operator"></div>
<div class="literal">&#34;errors&#34;</div><div class="operator"></div>
<div class="literal">&#34;fmt&#34;</div><div class="operator"></div>
<div class="literal">&#34;net/http&#34;</div><div class="operator"></div>
<div class="literal">&#34;regexp&#34;</div><div class="operator"></div>
Expand Down Expand Up @@ -432,6 +434,79 @@
<div class="keyword">return</div> <div class="ident">strings</div><div class="operator">.</div><div class="ident">Split</div><div class="operator">(</div><div class="ident">arrayParam</div><div class="operator">,</div> <div class="literal">&#34;,&#34;</div><div class="operator">)</div><div class="operator"></div>
<div class="operator">}</div><div class="operator"></div>

</code></pre></td>
</tr>

<tr class="section">
<td class="doc"><p>ReadClusterListFromPath retrieves list of clusters from request's path
if it's not possible, it writes http error to the writer and returns false</p>
</td>
<td class="code"><pre><code><div class="keyword">func</div> <div class="ident">ReadClusterListFromPath</div><div class="operator">(</div><div class="ident">writer</div> <div class="ident">http</div><div class="operator">.</div><div class="ident">ResponseWriter</div><div class="operator">,</div> <div class="ident">request</div> <div class="operator">*</div><div class="ident">http</div><div class="operator">.</div><div class="ident">Request</div><div class="operator">)</div> <div class="operator">(</div><div class="operator">[</div><div class="operator">]</div><div class="ident">string</div><div class="operator">,</div> <div class="ident">bool</div><div class="operator">)</div> <div class="operator">{</div>
<div class="ident">rawClusterList</div><div class="operator">,</div> <div class="ident">err</div> <div class="operator">:=</div> <div class="ident">GetRouterParam</div><div class="operator">(</div><div class="ident">request</div><div class="operator">,</div> <div class="literal">&#34;cluster_list&#34;</div><div class="operator">)</div><div class="operator"></div>
<div class="keyword">if</div> <div class="ident">err</div> <div class="operator">!=</div> <div class="ident">nil</div> <div class="operator">{</div>
<div class="ident">types</div><div class="operator">.</div><div class="ident">HandleServerError</div><div class="operator">(</div><div class="ident">writer</div><div class="operator">,</div> <div class="ident">err</div><div class="operator">)</div><div class="operator"></div>
<div class="keyword">return</div> <div class="operator">[</div><div class="operator">]</div><div class="ident">string</div><div class="operator">{</div><div class="operator">}</div><div class="operator">,</div> <div class="ident">false</div><div class="operator"></div>
<div class="operator">}</div><div class="operator"></div>

</code></pre></td>
</tr>

<tr class="section">
<td class="doc"><p>basic check that should not happen in reality (because of Gorilla mux checks)</p>
</td>
<td class="code"><pre><code> <div class="keyword">if</div> <div class="ident">rawClusterList</div> <div class="operator">==</div> <div class="literal">&#34;&#34;</div> <div class="operator">{</div>
<div class="ident">types</div><div class="operator">.</div><div class="ident">HandleServerError</div><div class="operator">(</div><div class="ident">writer</div><div class="operator">,</div> <div class="ident">errors</div><div class="operator">.</div><div class="ident">New</div><div class="operator">(</div><div class="literal">&#34;cluster list is empty&#34;</div><div class="operator">)</div><div class="operator">)</div><div class="operator"></div>
<div class="keyword">return</div> <div class="operator">[</div><div class="operator">]</div><div class="ident">string</div><div class="operator">{</div><div class="operator">}</div><div class="operator">,</div> <div class="ident">false</div><div class="operator"></div>
<div class="operator">}</div><div class="operator"></div>

</code></pre></td>
</tr>

<tr class="section">
<td class="doc"><p>split the list into items</p>
</td>
<td class="code"><pre><code> <div class="ident">clusterList</div> <div class="operator">:=</div> <div class="ident">strings</div><div class="operator">.</div><div class="ident">Split</div><div class="operator">(</div><div class="ident">rawClusterList</div><div class="operator">,</div> <div class="literal">&#34;,&#34;</div><div class="operator">)</div><div class="operator"></div>

</code></pre></td>
</tr>

<tr class="section">
<td class="doc"><p>everything seems ok -&gt; return list of clusters</p>
</td>
<td class="code"><pre><code> <div class="keyword">return</div> <div class="ident">clusterList</div><div class="operator">,</div> <div class="ident">true</div><div class="operator"></div>
<div class="operator">}</div><div class="operator"></div>

</code></pre></td>
</tr>

<tr class="section">
<td class="doc"><p>ReadClusterListFromBody retrieves list of clusters from request's body
if it's not possible, it writes http error to the writer and returns false</p>
</td>
<td class="code"><pre><code><div class="keyword">func</div> <div class="ident">ReadClusterListFromBody</div><div class="operator">(</div><div class="ident">writer</div> <div class="ident">http</div><div class="operator">.</div><div class="ident">ResponseWriter</div><div class="operator">,</div> <div class="ident">request</div> <div class="operator">*</div><div class="ident">http</div><div class="operator">.</div><div class="ident">Request</div><div class="operator">)</div> <div class="operator">(</div><div class="operator">[</div><div class="operator">]</div><div class="ident">string</div><div class="operator">,</div> <div class="ident">bool</div><div class="operator">)</div> <div class="operator">{</div>
<div class="keyword">var</div> <div class="ident">clusterList</div> <div class="ident">types</div><div class="operator">.</div><div class="ident">ClusterListInRequest</div><div class="operator"></div>

</code></pre></td>
</tr>

<tr class="section">
<td class="doc"><p>try to read cluster list from request parameter</p>
</td>
<td class="code"><pre><code> <div class="ident">err</div> <div class="operator">:=</div> <div class="ident">json</div><div class="operator">.</div><div class="ident">NewDecoder</div><div class="operator">(</div><div class="ident">request</div><div class="operator">.</div><div class="ident">Body</div><div class="operator">)</div><div class="operator">.</div><div class="ident">Decode</div><div class="operator">(</div><div class="operator">&amp;</div><div class="ident">clusterList</div><div class="operator">)</div><div class="operator"></div>
<div class="keyword">if</div> <div class="ident">err</div> <div class="operator">!=</div> <div class="ident">nil</div> <div class="operator">{</div>
<div class="ident">types</div><div class="operator">.</div><div class="ident">HandleServerError</div><div class="operator">(</div><div class="ident">writer</div><div class="operator">,</div> <div class="ident">err</div><div class="operator">)</div><div class="operator"></div>
<div class="keyword">return</div> <div class="operator">[</div><div class="operator">]</div><div class="ident">string</div><div class="operator">{</div><div class="operator">}</div><div class="operator">,</div> <div class="ident">false</div><div class="operator"></div>
<div class="operator">}</div><div class="operator"></div>

</code></pre></td>
</tr>

<tr class="section">
<td class="doc"><p>everything seems ok -&gt; return list of clusters</p>
</td>
<td class="code"><pre><code> <div class="keyword">return</div> <div class="ident">clusterList</div><div class="operator">.</div><div class="ident">Clusters</div><div class="operator">,</div> <div class="ident">true</div><div class="operator"></div>
<div class="operator">}</div><div class="operator"></div>

</code></pre></td>
</tr>

Expand Down
Loading

0 comments on commit bec407e

Please sign in to comment.