<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>HTTP on Nalar</title>
    <link>https://nalar.dev/tags/http/</link>
    <description>Recent content in HTTP on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 01 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/http/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Go Context Timeouts and Request Cancellation</title>
      <link>https://nalar.dev/go-context-timeouts-and-request-cancellation/</link>
      <pubDate>Tue, 01 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/go-context-timeouts-and-request-cancellation/</guid>
      <description>&lt;p&gt;A Go HTTP handler can outlive the request that started it unless the work inside the handler pays attention to cancellation. That matters when a client disconnects, an upstream request takes too long, or a database query is no longer useful.&lt;/p&gt;&#xA;&lt;p&gt;Go solves this with &lt;code&gt;context.Context&lt;/code&gt;. Every incoming &lt;code&gt;*http.Request&lt;/code&gt; already has a context, and that context is canceled when the client connection closes, the request is canceled by HTTP/2, or the handler returns. You can also derive a shorter deadline for work that should not consume the entire request lifetime.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Graceful HTTP Server Shutdown in Go</title>
      <link>https://nalar.dev/graceful-http-server-shutdown-in-go/</link>
      <pubDate>Tue, 01 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/graceful-http-server-shutdown-in-go/</guid>
      <description>&lt;p&gt;Stopping a web server with &lt;code&gt;Ctrl+C&lt;/code&gt; looks harmless during development, but production deployments need a more careful shutdown process. If a process exits immediately, active HTTP requests can be interrupted, clients may receive connection errors, and in-flight work can be left unfinished.&lt;/p&gt;&#xA;&lt;p&gt;Go&amp;rsquo;s standard library already provides the pieces needed for a clean shutdown. The main tools are &lt;code&gt;os/signal&lt;/code&gt;, &lt;code&gt;context&lt;/code&gt;, and &lt;code&gt;http.Server.Shutdown&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This guide shows a practical pattern for shutting down an HTTP server when the process receives &lt;code&gt;SIGINT&lt;/code&gt; or &lt;code&gt;SIGTERM&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Testing Go HTTP Handlers with httptest</title>
      <link>https://nalar.dev/testing-go-http-handlers-with-httptest/</link>
      <pubDate>Tue, 01 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/testing-go-http-handlers-with-httptest/</guid>
      <description>&lt;p&gt;HTTP handlers are one of the easiest parts of a Go service to test well. You usually do not need to bind a real network port, start the entire application, or depend on an external test framework.&lt;/p&gt;&#xA;&lt;p&gt;Go&amp;rsquo;s standard library provides &lt;code&gt;net/http/httptest&lt;/code&gt;, which can construct HTTP requests, capture handler responses, and even start temporary HTTP servers when a real client-server round trip matters.&lt;/p&gt;&#xA;&lt;p&gt;This guide builds a small JSON endpoint and tests it at several useful levels.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
