Posts List

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:

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.