Custom Http Basic authentication using Gin framework

Recently, I have been working with gin framework in golang. So in our case, we needed to add HTTP basic authentication.

gin framework provides basic auth in following way where we need to provide accounts information(pairs of username and passwords)

But It does not work well when you want to authenticate username and password against database. So I wrote following middleware to handle it.

This way it avoids you to specify all username/password pairs in middleware for basicauth.

Written on September 7, 2018