<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Akshat Agal</title>
    <description>The latest articles on DEV Community by Akshat Agal (@akshatagal1).</description>
    <link>https://dev.to/akshatagal1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4121135%2Ff8959ce4-563b-489e-aaf3-7fb1828dccfc.jpeg</url>
      <title>DEV Community: Akshat Agal</title>
      <link>https://dev.to/akshatagal1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akshatagal1"/>
    <language>en</language>
    <item>
      <title>Building a Fast REST API in Go using GoFr Framework</title>
      <dc:creator>Akshat Agal</dc:creator>
      <pubDate>Fri, 11 Sep 2026 16:09:54 +0000</pubDate>
      <link>https://dev.to/akshatagal1/building-a-fast-rest-api-in-go-using-gofr-framework-5c82</link>
      <guid>https://dev.to/akshatagal1/building-a-fast-rest-api-in-go-using-gofr-framework-5c82</guid>
      <description>&lt;h1&gt;
  
  
  Getting Started with GoFr: Building a Simple Go API
&lt;/h1&gt;

&lt;p&gt;When working with Go, setting up a microservice can involve a lot of repetitive things like handling HTTP routes, logging, database connections, and monitoring.&lt;/p&gt;

&lt;p&gt;GoFr is an open-source framework for building HTTP microservices in Go. It provides some of these things out of the box, so we can focus more on writing the actual application.&lt;/p&gt;

&lt;p&gt;In this article, I'll show how to create a small API using GoFr and run it locally.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Step 1: Create the Go Project
&lt;/h2&gt;

&lt;p&gt;First, create a new folder for the project and move into it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;gofr-quickstart
&lt;span class="nb"&gt;cd &lt;/span&gt;gofr-quickstart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now initialize a Go module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go mod init gofr-quickstart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, install GoFr using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="sb"&gt;`&lt;/span&gt;go get gofr.dev/pkg/gofr&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all we need for the initial setup.&lt;/p&gt;




&lt;h2&gt;
  
  
  💻 Step 2: Create the API
&lt;/h2&gt;

&lt;p&gt;Create a file called &lt;code&gt;main.go&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"gofr.dev/pkg/gofr"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gofr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/api/welcome"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gofr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;interface&lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s"&gt;"status"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Welcome to GoFr Framework!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There isn't much code here.&lt;/p&gt;

&lt;p&gt;First, &lt;code&gt;gofr.New()&lt;/code&gt; creates the GoFr application. Then we use &lt;code&gt;app.GET()&lt;/code&gt; to create a GET endpoint at &lt;code&gt;/api/welcome&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The endpoint returns a simple map containing a status and a message.&lt;/p&gt;

&lt;p&gt;Finally, &lt;code&gt;app.Run()&lt;/code&gt; starts the server.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏃 Step 3: Run the Application
&lt;/h2&gt;

&lt;p&gt;Now run the application from the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The GoFr application starts the HTTP server, which runs on port &lt;code&gt;8000&lt;/code&gt; by default.&lt;/p&gt;

&lt;p&gt;We can now test the endpoint using &lt;code&gt;curl&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://localhost:8000/api/welcome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Welcome to GoFr Framework!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"success"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also open the endpoint directly in your browser:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://localhost:8000/api/welcome&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🔥 Why GoFr?
&lt;/h2&gt;

&lt;p&gt;One reason to use GoFr is that it handles some common microservice requirements without us having to build everything from scratch.&lt;/p&gt;

&lt;p&gt;Some of the features include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structured logging&lt;/li&gt;
&lt;li&gt;Health checks&lt;/li&gt;
&lt;li&gt;Metrics&lt;/li&gt;
&lt;li&gt;Database integrations&lt;/li&gt;
&lt;li&gt;Support for databases such as MySQL, PostgreSQL, Redis, and MongoDB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This can be useful when building Go services where you don't want to spend time setting up the same basic infrastructure for every project.&lt;/p&gt;

&lt;p&gt;GoFr is also open source, so you can check out the source code and documentation on GitHub.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/gofr-dev/gofr" rel="noopener noreferrer"&gt;https://github.com/gofr-dev/gofr&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 Conclusion
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we created a small Go project, installed GoFr, added a GET endpoint, and ran the application locally.&lt;/p&gt;

&lt;p&gt;The example is simple, but it gives you the basic idea of how routing works in GoFr. From here, you can start adding things like databases, authentication, more API endpoints, and other microservice functionality.&lt;/p&gt;

&lt;p&gt;If you're just getting started with GoFr, this is a good small project to begin with before moving on to a larger service.&lt;/p&gt;




</description>
      <category>go</category>
      <category>webdev</category>
      <category>gofr</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
