Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Source/VaRest/Private/VaRestSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void UVaRestSubsystem::Deinitialize()
Super::Deinitialize();
}

void UVaRestSubsystem::CallURL(const FString& URL, EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback)
void UVaRestSubsystem::CallURL(const FString& URL, EVaRestRequestVerb Verb, const TMap<FString, FString> headers, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback)
{
// Check we have valid data json
if (VaRestJson == nullptr)
Expand All @@ -43,6 +43,11 @@ void UVaRestSubsystem::CallURL(const FString& URL, EVaRestRequestVerb Verb, EVaR
Request->SetVerb(Verb);
Request->SetContentType(ContentType);
Request->SetRequestObject(VaRestJson);

for (const TPair<FString, FString>& pair : headers)
{
Request->SetHeader(pair.Key, pair.Value);
}

FVaRestCallResponse Response;
Response.Request = Request;
Expand Down
3 changes: 2 additions & 1 deletion Source/VaRest/Public/VaRestSubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct FVaRestCallResponse

UPROPERTY()
UVaRestRequestJSON* Request;


UPROPERTY()
FVaRestCallDelegate Callback;
Expand Down Expand Up @@ -51,7 +52,7 @@ class VAREST_API UVaRestSubsystem : public UEngineSubsystem
public:
/** Easy way to process http requests */
UFUNCTION(BlueprintCallable, Category = "VaRest|Utility")
void CallURL(const FString& URL, EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback);
void CallURL(const FString& URL, EVaRestRequestVerb Verb, const TMap<FString, FString> headers, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback);

/** Called when URL is processed (one for both success/unsuccess events)*/
void OnCallComplete(UVaRestRequestJSON* Request);
Expand Down