UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ExternalRpcRegistry.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Containers/Array.h"
5#include "Containers/Map.h"
7#include "CoreTypes.h"
8#include "HttpPath.h"
10#include "HttpResultCallback.h"
11#include "HttpRouteHandle.h"
12#include "HttpServerRequest.h"
13#include "IHttpRouter.h"
14#include "Logging/LogMacros.h"
15#include "UObject/NameTypes.h"
16#include "UObject/Object.h"
19
20#include "ExternalRpcRegistry.generated.h"
21
23
24USTRUCT()
26{
28public:
29 FString Name;
30 FString Type;
31 FString Desc;
32 bool bIsOptional = false;
33
35 FExternalRpcArgumentDesc(FString InName, FString InType, FString InDesc, bool bInIsOptional = false)
36 {
37 Name = InName;
38 Type = InType;
39 Desc = InDesc;
40 bIsOptional = bInIsOptional;
41 }
42
44 {
45 return
46 Name == Other.Name &&
47 Type == Other.Type &&
48 Desc == Other.Desc &&
49 bIsOptional == Other.bIsOptional;
50 }
51
53 {
54 return !(*this == Other);
55 }
56};
57
58USTRUCT()
60{
62public:
68 FString RpcCategory = TEXT("Unknown");
69 bool bAlwaysOn = false;
70
71 FExternalRouteInfo() = default;
72
74 {
75 RouteName = InRouteName;
76 RoutePath = InRoutePath;
77 RequestVerbs = InRequestVerbs;
78 InputContentType = InContentType;
79 ExpectedArguments = InArguments;
80 RpcCategory = InCategory;
81 bAlwaysOn = false;
82 }
83
85 {
86 return
87 RouteName == Other.RouteName &&
88 RoutePath == Other.RoutePath &&
89 RequestVerbs == Other.RequestVerbs &&
90 InputContentType == Other.InputContentType &&
91 ExpectedArguments == Other.ExpectedArguments &&
92 RpcCategory == Other.RpcCategory &&
93 bAlwaysOn == Other.bAlwaysOn;
94 }
95
97 {
98 return !(*this == Other);
99 }
100};
101
102USTRUCT()
120
121USTRUCT()
123{
125public:
126 FString RpcName;
127 FString RequestBody;
129 FRpcLedgerEntry() = default;
130 FRpcLedgerEntry(FString InName, FString InBody)
131 {
132 RpcName = InName;
133 RequestBody = InBody;
134 RequestTime = FDateTime::UtcNow();
135 }
136};
137
138
139USTRUCT()
141{
143 FRpcConfig() = default;
144
145 TMap<FString, int> PortMapping;
146
147 // it is valid to have mappings, but no active port, in the case of a client with multiple endpoint hosts
148 int ActiveHostPort = 0;
149};
150
151
156UCLASS(MinimalAPI)
158{
160protected:
165
166public:
167 static EXTERNALRPCREGISTRY_API UExternalRpcRegistry * GetInstance();
168 static EXTERNALRPCREGISTRY_API bool IsEnabled();
169 static EXTERNALRPCREGISTRY_API const FRpcConfig& GetRpcConfig();
171
172 int PortToUse = 0;
173 int RequestLedgerCapacity = 10;
174
178 EXTERNALRPCREGISTRY_API bool IsActiveRpcCategory(FString InCategory);
179
183 EXTERNALRPCREGISTRY_API bool GetRegisteredRoute(FName RouteName, FExternalRouteInfo& OutRouteInfo);
184
185 EXTERNALRPCREGISTRY_API void RegisterNewRoute(FExternalRouteInfo InRouteInfo, const FHttpRequestHandler& Handler, bool bOverrideIfBound = false);
186
191 EXTERNALRPCREGISTRY_API void RegisterNewRouteWithArguments(FName RouteName, const FHttpPath& HttpPath, const EHttpServerRequestVerbs& RequestVerbs, const FHttpRequestHandler& Handler, TArray<FExternalRpcArgumentDesc> InArguments, bool bOverrideIfBound = false, bool bIsAlwaysOn = false, FString OptionalCategory = TEXT("Unknown"), FString OptionalContentType = {});
192
197 EXTERNALRPCREGISTRY_API void RegisterNewRoute(FName RouteName, const FHttpPath& HttpPath, const EHttpServerRequestVerbs& RequestVerbs, const FHttpRequestHandler& Handler, bool bOverrideIfBound = false, bool bIsAlwaysOn = false, FString OptionalCategory = TEXT("Unknown"), FString OptionalContentType = {}, FString OptionalExpectedFormat = {});
198
202 EXTERNALRPCREGISTRY_API void CleanUpAllRoutes();
203
208 EXTERNALRPCREGISTRY_API void CleanUpRoute(FName RouteName, bool bFailIfUnbound = false);
209
214 EXTERNALRPCREGISTRY_API bool HttpListOpenRoutes(const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete);
218 EXTERNALRPCREGISTRY_API void AddRequestToLedger(const FHttpServerRequest& Request);
219
224 EXTERNALRPCREGISTRY_API bool HttpPrintRequestLedger(const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete);
225
231
232
237 EXTERNALRPCREGISTRY_API bool HttpSwaggerUI(const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete);
238
239};
#define TEXT(x)
Definition Platform.h:1272
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
OnComplete(MoveTemp(Response))
EHttpServerRequestVerbs
Definition HttpServerRequest.h:11
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
Definition NameTypes.h:617
Definition Array.h:670
Definition DelegateSignatureImpl.inl:310
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition ExternalRpcRegistry.h:158
TMap< FName, FExternalRouteDesc > RegisteredRoutes
Definition ExternalRpcRegistry.h:162
static EXTERNALRPCREGISTRY_API UExternalRpcRegistry * ObjectInstance
Definition ExternalRpcRegistry.h:161
TArray< FString > ActiveRpcCategories
Definition ExternalRpcRegistry.h:163
EXTERNALRPCREGISTRY_API bool HttpListOASv3JSONRoutes(const FHttpServerRequest &Request, const FHttpResultCallback &OnComplete)
TArray< FRpcLedgerEntry > RequestLedger
Definition ExternalRpcRegistry.h:164
Definition Object.h:95
Definition DateTime.h:76
static CORE_API FDateTime UtcNow()
Definition DateTime.cpp:980
Definition ExternalRpcRegistry.h:104
FExternalRouteDesc(FHttpRouteHandle InHandle, FString InContentType, TArray< FExternalRpcArgumentDesc > InArguments, FString InCategory="")
Definition ExternalRpcRegistry.h:112
FHttpRouteHandle Handle
Definition ExternalRpcRegistry.h:107
TArray< FExternalRpcArgumentDesc > ExpectedArguments
Definition ExternalRpcRegistry.h:110
FString InputContentType
Definition ExternalRpcRegistry.h:108
FString RpcCategory
Definition ExternalRpcRegistry.h:109
FExternalRouteDesc()=default
Definition ExternalRpcRegistry.h:60
FName RouteName
Definition ExternalRpcRegistry.h:63
FExternalRouteInfo(FName InRouteName, FHttpPath InRoutePath, EHttpServerRequestVerbs InRequestVerbs, FString InCategory=TEXT("Unknown"), bool bInAlwaysOn=false, FString InContentType={}, TArray< FExternalRpcArgumentDesc > InArguments=TArray< FExternalRpcArgumentDesc >())
Definition ExternalRpcRegistry.h:73
FExternalRouteInfo()=default
FString InputContentType
Definition ExternalRpcRegistry.h:66
bool operator==(const FExternalRouteInfo &Other) const
Definition ExternalRpcRegistry.h:84
TArray< FExternalRpcArgumentDesc > ExpectedArguments
Definition ExternalRpcRegistry.h:67
FHttpPath RoutePath
Definition ExternalRpcRegistry.h:64
bool operator!=(const FExternalRouteInfo &Other) const
Definition ExternalRpcRegistry.h:96
Definition ExternalRpcRegistry.h:26
FExternalRpcArgumentDesc()=default
FExternalRpcArgumentDesc(FString InName, FString InType, FString InDesc, bool bInIsOptional=false)
Definition ExternalRpcRegistry.h:35
bool operator!=(const FExternalRpcArgumentDesc &Other) const
Definition ExternalRpcRegistry.h:52
FString Desc
Definition ExternalRpcRegistry.h:31
FString Type
Definition ExternalRpcRegistry.h:30
FString Name
Definition ExternalRpcRegistry.h:29
bool operator==(const FExternalRpcArgumentDesc &Other) const
Definition ExternalRpcRegistry.h:43
Definition HttpPath.h:12
Definition HttpServerRequest.h:24
Definition ExternalRpcRegistry.h:141
Definition ExternalRpcRegistry.h:123
FRpcLedgerEntry()=default
FString RpcName
Definition ExternalRpcRegistry.h:126
FDateTime RequestTime
Definition ExternalRpcRegistry.h:128
FRpcLedgerEntry(FString InName, FString InBody)
Definition ExternalRpcRegistry.h:130
FString RequestBody
Definition ExternalRpcRegistry.h:127