DRY HTTP Requests for Unreal with Data Tables
Announcing UnrealTableHTTP - a Data Table driven HTTP requests package for Unreal with C++ and Blueprint APIs.
As of writing, EPIC offers the C++ based FHttpModule and there are a few marketplace plugins that enable making HTTP requests from Blueprints like this one. In either case, each request needs to be configured independent of others. With UnrealTableHTTP developers can now setup re-usable configuration for HTTP requests using Data Tables and trigger them by calling
Send on the appropriate table row representing the desired request.
At the heart of the package are two Data Tables inheriting from the FHttpServiceRow and FHttpRequestRow. The service rows defines an HTTP service which has a base-url and set of default headers which will be used (or overriden) by the requests associated with the service.
The request row defines a request belonging to a given service. It has the path, headers, method type (post, get, patch, put & delete) along with request payload. The package does not make any assumption about the content-type of the payload and accepts any
FString typed value. This behaviour thus requires that developers supply their own serialization logic to translate between native data-structure to wire formats like JSON, XML and others.
Each request is linked to a service and inherits the headers and timeout values from the parent service.
Once the request is configured, it can be triggered by instancing an object of the class UDataTableHttpRequest and assigning the desired row from FHttpRequestRow table created earlier to the field RequestRow followed by a call to Send which dispatches the request.
The requests themselves are executed asyncronously and the responses can be handled via OnRequestSucceed or OnRequestFailed delegates. Alternatively, reusable handlers for the request can be defined in the request data table via the ResponseHandler field of the type UDataTableHttpResponseHandler which is also has a blueprint API which exposes two overridable functions - HandleSuccess and HandleFailure.
While we are using this package extensively in our first title Paperplanes, this is still limited in functionality and must be considered an alpha release.
Wishlist Paperplanes on Steam today.