HTTP Requests

Basic explanation of HTTP Requests in the tekos flow.

Now days all apps use the HTTP Requests and we either, our whole ecosystem is based on the requests.

In this tutorial we are going to showcase some example usage of the requests in the flow.

The Tekos Flow comes with three basic HTTP nodes which are:

  1. HTTP Request - Sends HTTP requests and returns the response.

  2. HTTP In - Creates an HTTP end-point for creating web services.

  3. HTTP Response - Sends responses back to requests received from an HTTP Input node

It is possible to even create web pages using the tekos flow.

List of available HTTP Methods:

Method

Description

GET

The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.

HEAD

The HEAD method asks for a response identical to that of a GET request, but without the response body.

POST

The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.

PUT

The PUT method replaces all current representations of the target resource with the request payload.

DELETE

The DELETE method deletes the specified resource.

CONNECT

The CONNECT method establishes a tunnel to the server identified by the target resource.

OPTIONS

The OPTIONS method is used to describe the communication options for the target resource.

TRACE

The TRACE method performs a message loop-back test along the path to the target resource.

PATCH

The PATCH method is used to apply partial modifications to a resource.

Using HTTP In & HTTP Response

Both of those nodes are often necessary to properly configure an endpoint

Let's create an POST endpoint in my flow to adres /tekos/documentation that just responses with payload "It's working!" and code 200 - OK.

Check the full list of available response codes https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

Above endpoint will be available under my flow instance adres "https://instance-name.tekos.co/tekos/documentation"

Using HTTP Request

This node allows you to do a HTTP Request to any service endpoint. We can use our previously created one using the HTTP In & HTTP Response, but let's use function node instead of change, and in this function we will enter simple command to iterate the number stored in the payload.

msg.payload++
return msg;

While we have our endpoint prepared let's create an flow with POST Request

As you can see we have an inject node to manually trigger the request, an function node, http request and a debug node, don't mind the change node it is just to hide my instance name.

Function node
msg.url = "https://instance-name.tekos.co/tekos/documentation"
msg.headers ={
    "Content-type": "application/json"
}
msg.payload = 10
return msg;

We have also set the msg.payload value to 10, while our endpoint have a function to iterate the msg.payload so the response from this endpoint should be 11. Let's take a look

Of course this is just a basic example of how to create endpoint and send an http request to it.

Last updated