10 Ways to Avoid Burnout

When I accepted my very first role as a Data Scientist, I was extremely grateful, happy and overjoyed that I had broken into this amazing, competitive field! Eager to learn and very passionate, I…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Creating RFC6902 JSON Patches in GoLang With HTTP PATCH Method

“You’re a Good man, with Good Heart. It’s hard for a Good Man to be the King.” — T’Chakka

HTTP is the widely used protocol for fetching resources over the web. It’s the building block for any data exchange that happens over the world wide web. Several applications that use HTTP protocol for accessing and storing resources needs a feature to partially modify the resources.

HTTP supports a PUT method that does a complete replacement of the resource. It overrides the resource with a completely new body and cannot be re-purposed for partial modification of resources.

In this article, we will learn how to apply a JSON patch to the existing resource in conjunction with the HTTP PATCH method in GoLang.

The JSON patch document can be used to partially update a resource. For instance, if you only need to modify one field of the resource, sending the entire new resource with just one field modified is not going to be a good option.

Considering we are going to make a remote call, PUTting a complete resource representation is going to utilize more bandwidth and might be a cumbersome job.

When used in combination with the HTTP PATCH method, it allows partial updates for HTTP APIs in a standards compliant way.

Sample JSON patch document.

Here are a few key differences between HTTP PUT and PATCH method.

Add a comment

Related posts:

Why I Came to Ireland for my MBA

I hopped on a long 20-hour journey consisting of 2 flight legs from Nigeria to Ireland in January 2017. It wasn’t the first time I was leaving home to study in a different country only this time…

Timeless Designs Featuring Surprise Details

The engagement ring is the most important piece of jewelry a bride-to-be will wear, so it’s no surprise that she spends months dreaming up the perfect ring. Every year, there’s a new set of…

The Art of Black Panther

This week I want to review a book titled the Marvel’s Black Panther: Art of the movie. The Art of Black Panther is an art book created by the Marvel Visual Production team and published by marvel…