Query JSON data using Golang (gojsonq package)

Most often developer needs to consume JSON data from other service and query over them. Querying JSON data is little time consuming. For the last few days I was working on a package for Golang to query JSON data easily. The idea and inspiration comes form PHP-JSONQ by Nahid Bin Azhar. Lets take a sample JSON data to start with: Now we are ready to query the data, lets see some examples ...

May 29, 2018 · 2 min · Saddam H

How to customize Laravel request throttle message in API response?

When you are using laravel api, then you must use throttling to protect your api from scrapping or any other attack. When you are limiting your api using laravel throttle then you get a html response message containing “Too Many Attempts.” In order to change the message in a custom format and json reponse follow the steps below: Create a new file ThrottleRequestsMiddleware.php in __ app/Http/Middleware/__ and paste the code below: ...

November 27, 2017 · 3 min · Saddam H

Let’s make a simple todo app with Go

Generally Go is perfect for building micro services, but it doesn’t mean that trivial MVC app are not easy to build. Go has built-in support for parsing html template, though we are not going to focus on that. First of all let’s write our go code for serving a html page and save it in a directory. In our case let’s call the directory todoapp and create a home.tpl file inside it. Paste the html in home.tpl, it doing some http call to our backend application. ...

November 24, 2017 · 5 min · Saddam H

An easy way to validate Go request

When building REST API or web applications using Go, an essential part is to validate the incoming request data. I have worked in some small and medium project in Golang, most of them are micro-services, providing restful api. I have used different way to validate incoming data. Lets start with particular one that I use frequently. For validating application/json or text/plain request, first I build a struct type of that particular request and add a validate method on the struct. Lets see an example: ...

November 22, 2017 · 2 min · Saddam H