Community

GUHADA Update: Response Status Code development

TEMCO | 03.26| 528

Welcome back again this week for another GUHADA development update!

At this time, we would like to explain what is “Restful API” and the development of the “response” code of GUHADA platform.

Please take your time reading through, since this may be an important aspect of GUHADA that you might want to know.

First, let's find out about the “Restful” API before getting into the “Response Code”.

So, what is “REST”?
The REST is described as below:

Representational State Transfer (REST)

REST is a software architectural style that defines a set of constraints to be used for creating Web services. Web services that conform to the REST architectural style, termed RESTful Web services (RWS), provide interoperability between computer systems on the Internet. RESTful Web services allow the requesting systems to access and manipulate textual representations of Web resources by using a uniform and predefined set of stateless operations. Other kinds of Web services, such as SOAP Web services, expose their own arbitrary sets of operations.

source: https://en.wikipedia.org/wiki/Representational_state_transfer

The REST is used accordingly for certain resources, to perform an operation of CRUD (Create, Read, Update, Delete), requesting to URI resource using the method, and the resources needed for the request is formed as Representation of Resource.

The specialty of the REST

Uniform interface

As long as it follows the HTTP standard, the interface can be used in android or iOS platforms that are not limited to specific language or coding, it is an architecture style that allows the manipulation of the URI designated resource.

Stateless

The server recognizes each request separately, and the previous one can not be the next request. So, the REST does not manage or save status information through cookies or session data. Due to the stateless nature of the REST, it has high service freedom, the development of it, is simple, since it does not manage the unnecessary information. This kind of statelessness grants aligning of the server processing method and reduces the burden on the server.

Cacheable

The REST uses HTTP which is a previous web standard, so it can use the web’s existing infrastructure. Accordingly, caching function can be applied in REST, and it is possible to use Last-modified or E-tag which is used in HTTP protocol standard to define caching, allowing efficient processing of a large number of requests.

Client-Server Architecture

While the REST supplies API, the client directly manages the user verification (session, login information etc.) and the role is specifically defined, so what needs to be developed is clearly distinguished and dependency of each other is reduced.

Self-Descriptiveness

REST is developed in a way that it can easily understand the nature of the request just by looking at the message. It is set up in such a way that Verb (Method) + Noun (URI), so it can define at which method is performing which activity.

Hierarchal Structure

API server purely executes the business logic, and beforehand, there is cryptographed user verification(ssl), load balancing etc. for setting up the hierarchy, producing flexibility of the structure. To simply put, through HA Proxy or Apache’s Reverse Proxy, the hierarchal structure goes further to create Micro Service Architecture through API gateway.

Response Development

Several images below show the programming structure of GUHADA’s API development.

The response is set up with GuhadaApiResult enum object and “Java Generic” (T). The java generic (T), sets up the class that will be used from the outside of the class. It is a programming method that creates general coding for reuse of diverse object types. The generic collection is used often for libraries.

Did not signal right away at the controller but justified by creating a BaseController. We have justified the framework by creating ExtendsBaseAbstractController, so that the developer can focus on content development.

The use at the Controller (Example)

By extending the BaseController, it is developed in a way that at the Controller, only the responseAPI needs to be justified and transferred.

The Result value (example)

Below shows the results of the post method call. First is without the parameter and the second is with the parameter. It is set up so that there is no need for the specific method to process at the client, by matching with response.

Post Method Example 1 (w/o Parameter)
Post Method Example 2 (w. Parameter)

Below is the result value of the “Get” method. It is showing the example with the parameter.

Get Method Example

We are continuously working to provide you with the updates and detail development process as we approach the launch of GUHADA in the second half of this year.

For next week, we will be back with the update, regarding “Error module”.

Please stay tuned for next week’s update!

Thank you for supporting TEMCO!

TEMCO: Innovative Supply Chain Data and E-Commerce Solution through Blockchain and Smart Contract technology.

Please visit us to learn more about the blockchain and smart contract based supply chain data/e-commerce platform!

▶TEMCO Chatroom: https://t.me/temcolabs
▶TEMCO Official Website: https://temco.io


GUHADA Update: Response Status Code development was originally published in TEMCO on Medium, where people are continuing the conversation by highlighting and responding to this story.

Comment 0

delete

Are you sure you want to delete this post?