<?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: Yosef Seboka</title>
    <description>The latest articles on DEV Community by Yosef Seboka (@yosefseboka).</description>
    <link>https://dev.to/yosefseboka</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1007849%2F77670e51-c9f7-46fe-8fdf-b3e808adaf29.jpg</url>
      <title>DEV Community: Yosef Seboka</title>
      <link>https://dev.to/yosefseboka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yosefseboka"/>
    <language>en</language>
    <item>
      <title>Gin VS Echo</title>
      <dc:creator>Yosef Seboka</dc:creator>
      <pubDate>Fri, 13 Jan 2023 23:24:44 +0000</pubDate>
      <link>https://dev.to/yosefseboka/gin-vs-echo-9h9</link>
      <guid>https://dev.to/yosefseboka/gin-vs-echo-9h9</guid>
      <description>&lt;p&gt;Gin and Echo are two popular web frameworks in the Go programming language. Both frameworks are designed to make it easy to build web applications, but they have some differences that may make one more suitable for your project than the other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gin&lt;/strong&gt; is a high-performance web framework that is designed for building APIs and web services. It is based on the httprouter package, which provides a fast and efficient routing engine. Gin is known for its lightweight and minimalistic design, making it easy to understand and use. It also supports middleware, which allows developers to execute code before or after a request is handled by the router. This can be used to perform a variety of tasks such as logging, authentication, and error handling.&lt;/p&gt;

&lt;p&gt;On the other hand, &lt;strong&gt;Echo&lt;/strong&gt; is a web framework that is designed for building web applications. It has a more robust set of features compared to Gin, including support for template rendering, built-in middleware, and support for WebSockets. Echo also supports group routing, which allows developers to organize their routes into logical groups. This can be useful for structuring large applications. Echo also has a built-in request validation and sanitization.&lt;/p&gt;

&lt;p&gt;Both Gin and Echo are open-source frameworks and actively maintained, both are also very fast, and easy to use. However, the choice will depend on the type of application you want to build. If you're looking to build a simple and lightweight API, Gin may be the better choice. On the other hand, if you're building a more complex web application with a lot of routes and features, Echo may be the better choice.&lt;/p&gt;

&lt;p&gt;In conclusion, both Gin and Echo are powerful web frameworks, each of them has its own strengths and weaknesses, it's up to the developer to decide which one is better suited for the specific project. Gin is lightweight and minimalistic, perfect for building API, while Echo is more robust and have more features and is perfect for building web applications. Both frameworks are fast, easy to use and actively maintained, so the decision should be based on the specific needs of the project.for further detail checkout their documentation &lt;br&gt;
&lt;a href="https://gin-gonic.com/docs/" rel="noopener noreferrer"&gt;gin&lt;/a&gt; &lt;br&gt;
&lt;a href="https://echo.labstack.com/" rel="noopener noreferrer"&gt;echo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Middleware in Golang Gin</title>
      <dc:creator>Yosef Seboka</dc:creator>
      <pubDate>Fri, 13 Jan 2023 23:19:18 +0000</pubDate>
      <link>https://dev.to/yosefseboka/middleware-in-golang-gin-5b68</link>
      <guid>https://dev.to/yosefseboka/middleware-in-golang-gin-5b68</guid>
      <description>&lt;p&gt;Middleware is a powerful feature that allows developers to execute code before or after a request is handled by the router. This can be used to perform a variety of tasks such as logging, authentication, and error handling.&lt;/p&gt;

&lt;p&gt;In Gin, middleware is defined as a function that takes in a context and a handler, and returns a new handler. The context is an object that holds information about the current request and response, and the handler is the function that will handle the request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func LoggingMiddleware() gin.HandlerFunc {
    return func(c *gin.Context) {
        log.Println(c.Request.Method, c.Request.URL.Path)
        c.Next()
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is also possible to use middleware on specific routes or groups of routes by passing the middleware as an argument to the GET(), POST(), etc. methods. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r.GET("/", LoggingMiddleware(), func(c *gin.Context) {
    c.String(200, "Hello, World!")
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the LoggingMiddleware will be executed before the handler function is called.&lt;/p&gt;

&lt;p&gt;Gin also provides a built-in middleware for handling errors, called Recovery. It will recover from any panics and logs the panic message. To use this middleware, you can add it to the router using the Use() method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r := gin.Default()
r.Use(gin.Recovery())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In conclusion, Middleware in Golang Gin is like the superhero sidekick of your web development journey. It's always there to save the day, whether it's logging requests, handling errors, or implementing authentication. With Gin's middleware feature, you can add functionality to your application without having to change the existing routing structure, it's like having a swiss army knife for your web development needs. So don't be shy, give your middleware some love, and watch it make your life as a developer a whole lot easier.&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
  </channel>
</rss>
