Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Class: HTTPRequestBuilder

smokingplaya edited this page May 24, 2024 · 13 revisions

The HTTPRequestBuilder class was created as an abstraction over sending HTTP requests.
It simplifies sending HTTP requests, makes it easier to understand.

Methods

new (constructor)

@argument URL (string) - The URL link that will be used to send the request.
@argument Method (enum METHODS) - The method through which the request will be sent.

Example

local req = HTTPRequestBuilder:new("https://google.com", METHODS.GET)

SetContentType

@description Sets content type of request

@argument Type (enum MIME_TYPES) - MIME type of content

Example

req:SetContentType(MIME_TYPES.JSON)

SetHeader

@description Sets header value of request

@argument HeaderName (string) - Name of header @argument HeaderValue (string) - Value of header

Example

req:SetHeader("Accept", MIME_TYPES.JSON)

SetCallback

@description Sets callback of request

@argument Callback (function(HTTPResponse) ) - Function, that calls when we got response of server

Clone this wiki locally