How to Built a Web Application with Fizz and Golang

How to Built a Web Application with Fizz and Golang

Learn how to built a web application with Fizz and Golang. Go (Golang) is an open source programming language that makes it easy to build simple, reliable, and efficient software. Fizz almost works the opposite way Connexion does. It generates an OAS file from our code.

Background

A bit of background before we start the article. When I develop a Python web service I use the Connexion library created by Zalando. It’s a great library which is built on top of Flask. It uses an OpenAPI Specification (OAS) file to handle input validation and routing for you. Therefore reducing the boilerplate code you need to write.

The main advantage of this is that we have a design-first approach to developing our API. We fully define the OAS then develop the code/web service. This also keeps the OAS up to date, helping to mitigate the issue of the code/documentation getting out of date. Especially when you share the OAS with other people (clients) to use. The last thing you want to do is give them an out-of-date file.

Anyways short story aside, recently I started learning Golang and developing a simple CRUD web service using Gin. However, I discovered (at least at the time of writing) there was no equivalent library to Connexion. The closest library I could find was Fizz.

What is Fizz?

Fizz almost works the opposite way Connexion does. It generates an OAS file from our code. Now again I prefer the Connexion approach because we just use the OAS file we created at the beginning of the project. However, this is the next best thing.

What I ended up doing was creating an OAS by hand. Then implementing that OAS using Golang and letting Fizz auto-generate the “new” OAS. This “new” OAS is the one that gets shared with clients and is kept up to date. In theory the OAS I defined manually can now be deleted as it’s not required anymore.

This solves the problem of our code getting out-of-date with the specification. Fizz also uses other libraries behind the scenes to help us reduce the boilerplate code similiar to how Connexion works.

Web Service

Now onto the real meat and potatoes of this article. We will create three different endpoints:

  • GET /healthcheck: Checks if the application is healthy or not
  • GET /pet/{name}: Get information about a single pet
  • PUT /pet/{name}: Update information about a single pet

golang web-development programming developer

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Golang Web Development:Th Best Programming Language in 2020

Golang Web Development is the new trend globally. Get all the details about the Golang development here. Hire Golang Developers.

Why Web Development is Important for your Business

With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...

Important Reasons to Hire a Professional Web Development Company

    You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...

Top Web Development Company in India

We are the best offshore web development company in India providing web applications on Blockchain, AI & Chatbots. 15+ Yrs Exp., Save upto 60% on development.

Software Developer vs Web Developer | Difference Web Developer & Software Developer

Software Developer vs Web Developer | Difference Web Developer & Software Developer | Software development and web development are normally used interchangeably. Although both include development, a software developer has different responsibilities from that of a web developer.