14
14
#include < QJsonDocument>
15
15
#include < QJsonObject>
16
16
#include < QVariantMap>
17
- # include < QRegularExpression >
17
+
18
18
19
19
#include " OAIApiRouter.h"
20
20
#include " OAIPetApiRequest.h"
@@ -29,7 +29,7 @@ OAIApiRouter::OAIApiRouter() {
29
29
}
30
30
31
31
OAIApiRouter::~OAIApiRouter (){
32
- qDebug () << " ~ApiRouter() " ;
32
+
33
33
delete OAIPetApiApiHandler;
34
34
delete OAIStoreApiApiHandler;
35
35
delete OAIUserApiApiHandler;
@@ -117,11 +117,7 @@ bool OAIApiRouter::handleRequestAndExtractPathParam(QHttpEngine::Socket *socket)
117
117
{
118
118
auto completePath = QString (" %1 %2" ).arg (" DELETE" ).arg (" /v2/pet/{petId}" ).toLower ();
119
119
if ( reqPath.startsWith (completePath.leftRef ( completePath.indexOf (QString (" /{" )))) ) {
120
- QRegularExpression parExpr ( R"( \{([^\/\\s]+)\})" );
121
- completePath.replace ( parExpr, R"( (?<\1>[^\/\s]+))" );
122
- completePath.append (" [\\ /]?$" );
123
- QRegularExpression pathExpr ( completePath );
124
- QRegularExpressionMatch match = pathExpr.match ( reqPath );
120
+ QRegularExpressionMatch match = getRequestMatch ( completePath, reqPath );
125
121
if ( match.hasMatch () ){
126
122
QString petId = match.captured (QString (" petId" ).toLower ());
127
123
auto reqObj = new OAIPetApiRequest (socket, OAIPetApiApiHandler);
@@ -133,11 +129,7 @@ bool OAIApiRouter::handleRequestAndExtractPathParam(QHttpEngine::Socket *socket)
133
129
{
134
130
auto completePath = QString (" %1 %2" ).arg (" GET" ).arg (" /v2/pet/{petId}" ).toLower ();
135
131
if ( reqPath.startsWith (completePath.leftRef ( completePath.indexOf (QString (" /{" )))) ) {
136
- QRegularExpression parExpr ( R"( \{([^\/\\s]+)\})" );
137
- completePath.replace ( parExpr, R"( (?<\1>[^\/\s]+))" );
138
- completePath.append (" [\\ /]?$" );
139
- QRegularExpression pathExpr ( completePath );
140
- QRegularExpressionMatch match = pathExpr.match ( reqPath );
132
+ QRegularExpressionMatch match = getRequestMatch ( completePath, reqPath );
141
133
if ( match.hasMatch () ){
142
134
QString petId = match.captured (QString (" petId" ).toLower ());
143
135
auto reqObj = new OAIPetApiRequest (socket, OAIPetApiApiHandler);
@@ -149,11 +141,7 @@ bool OAIApiRouter::handleRequestAndExtractPathParam(QHttpEngine::Socket *socket)
149
141
{
150
142
auto completePath = QString (" %1 %2" ).arg (" POST" ).arg (" /v2/pet/{petId}" ).toLower ();
151
143
if ( reqPath.startsWith (completePath.leftRef ( completePath.indexOf (QString (" /{" )))) ) {
152
- QRegularExpression parExpr ( R"( \{([^\/\\s]+)\})" );
153
- completePath.replace ( parExpr, R"( (?<\1>[^\/\s]+))" );
154
- completePath.append (" [\\ /]?$" );
155
- QRegularExpression pathExpr ( completePath );
156
- QRegularExpressionMatch match = pathExpr.match ( reqPath );
144
+ QRegularExpressionMatch match = getRequestMatch ( completePath, reqPath );
157
145
if ( match.hasMatch () ){
158
146
QString petId = match.captured (QString (" petId" ).toLower ());
159
147
auto reqObj = new OAIPetApiRequest (socket, OAIPetApiApiHandler);
@@ -165,11 +153,7 @@ bool OAIApiRouter::handleRequestAndExtractPathParam(QHttpEngine::Socket *socket)
165
153
{
166
154
auto completePath = QString (" %1 %2" ).arg (" POST" ).arg (" /v2/pet/{petId}/uploadImage" ).toLower ();
167
155
if ( reqPath.startsWith (completePath.leftRef ( completePath.indexOf (QString (" /{" )))) ) {
168
- QRegularExpression parExpr ( R"( \{([^\/\\s]+)\})" );
169
- completePath.replace ( parExpr, R"( (?<\1>[^\/\s]+))" );
170
- completePath.append (" [\\ /]?$" );
171
- QRegularExpression pathExpr ( completePath );
172
- QRegularExpressionMatch match = pathExpr.match ( reqPath );
156
+ QRegularExpressionMatch match = getRequestMatch ( completePath, reqPath );
173
157
if ( match.hasMatch () ){
174
158
QString petId = match.captured (QString (" petId" ).toLower ());
175
159
auto reqObj = new OAIPetApiRequest (socket, OAIPetApiApiHandler);
@@ -181,11 +165,7 @@ bool OAIApiRouter::handleRequestAndExtractPathParam(QHttpEngine::Socket *socket)
181
165
{
182
166
auto completePath = QString (" %1 %2" ).arg (" DELETE" ).arg (" /v2/store/order/{orderId}" ).toLower ();
183
167
if ( reqPath.startsWith (completePath.leftRef ( completePath.indexOf (QString (" /{" )))) ) {
184
- QRegularExpression parExpr ( R"( \{([^\/\\s]+)\})" );
185
- completePath.replace ( parExpr, R"( (?<\1>[^\/\s]+))" );
186
- completePath.append (" [\\ /]?$" );
187
- QRegularExpression pathExpr ( completePath );
188
- QRegularExpressionMatch match = pathExpr.match ( reqPath );
168
+ QRegularExpressionMatch match = getRequestMatch ( completePath, reqPath );
189
169
if ( match.hasMatch () ){
190
170
QString orderId = match.captured (QString (" orderId" ).toLower ());
191
171
auto reqObj = new OAIStoreApiRequest (socket, OAIStoreApiApiHandler);
@@ -197,11 +177,7 @@ bool OAIApiRouter::handleRequestAndExtractPathParam(QHttpEngine::Socket *socket)
197
177
{
198
178
auto completePath = QString (" %1 %2" ).arg (" GET" ).arg (" /v2/store/order/{orderId}" ).toLower ();
199
179
if ( reqPath.startsWith (completePath.leftRef ( completePath.indexOf (QString (" /{" )))) ) {
200
- QRegularExpression parExpr ( R"( \{([^\/\\s]+)\})" );
201
- completePath.replace ( parExpr, R"( (?<\1>[^\/\s]+))" );
202
- completePath.append (" [\\ /]?$" );
203
- QRegularExpression pathExpr ( completePath );
204
- QRegularExpressionMatch match = pathExpr.match ( reqPath );
180
+ QRegularExpressionMatch match = getRequestMatch ( completePath, reqPath );
205
181
if ( match.hasMatch () ){
206
182
QString orderId = match.captured (QString (" orderId" ).toLower ());
207
183
auto reqObj = new OAIStoreApiRequest (socket, OAIStoreApiApiHandler);
@@ -213,11 +189,7 @@ bool OAIApiRouter::handleRequestAndExtractPathParam(QHttpEngine::Socket *socket)
213
189
{
214
190
auto completePath = QString (" %1 %2" ).arg (" DELETE" ).arg (" /v2/user/{username}" ).toLower ();
215
191
if ( reqPath.startsWith (completePath.leftRef ( completePath.indexOf (QString (" /{" )))) ) {
216
- QRegularExpression parExpr ( R"( \{([^\/\\s]+)\})" );
217
- completePath.replace ( parExpr, R"( (?<\1>[^\/\s]+))" );
218
- completePath.append (" [\\ /]?$" );
219
- QRegularExpression pathExpr ( completePath );
220
- QRegularExpressionMatch match = pathExpr.match ( reqPath );
192
+ QRegularExpressionMatch match = getRequestMatch ( completePath, reqPath );
221
193
if ( match.hasMatch () ){
222
194
QString username = match.captured (QString (" username" ).toLower ());
223
195
auto reqObj = new OAIUserApiRequest (socket, OAIUserApiApiHandler);
@@ -229,11 +201,7 @@ bool OAIApiRouter::handleRequestAndExtractPathParam(QHttpEngine::Socket *socket)
229
201
{
230
202
auto completePath = QString (" %1 %2" ).arg (" GET" ).arg (" /v2/user/{username}" ).toLower ();
231
203
if ( reqPath.startsWith (completePath.leftRef ( completePath.indexOf (QString (" /{" )))) ) {
232
- QRegularExpression parExpr ( R"( \{([^\/\\s]+)\})" );
233
- completePath.replace ( parExpr, R"( (?<\1>[^\/\s]+))" );
234
- completePath.append (" [\\ /]?$" );
235
- QRegularExpression pathExpr ( completePath );
236
- QRegularExpressionMatch match = pathExpr.match ( reqPath );
204
+ QRegularExpressionMatch match = getRequestMatch ( completePath, reqPath );
237
205
if ( match.hasMatch () ){
238
206
QString username = match.captured (QString (" username" ).toLower ());
239
207
auto reqObj = new OAIUserApiRequest (socket, OAIUserApiApiHandler);
@@ -245,11 +213,7 @@ bool OAIApiRouter::handleRequestAndExtractPathParam(QHttpEngine::Socket *socket)
245
213
{
246
214
auto completePath = QString (" %1 %2" ).arg (" PUT" ).arg (" /v2/user/{username}" ).toLower ();
247
215
if ( reqPath.startsWith (completePath.leftRef ( completePath.indexOf (QString (" /{" )))) ) {
248
- QRegularExpression parExpr ( R"( \{([^\/\\s]+)\})" );
249
- completePath.replace ( parExpr, R"( (?<\1>[^\/\s]+))" );
250
- completePath.append (" [\\ /]?$" );
251
- QRegularExpression pathExpr ( completePath );
252
- QRegularExpressionMatch match = pathExpr.match ( reqPath );
216
+ QRegularExpressionMatch match = getRequestMatch ( completePath, reqPath );
253
217
if ( match.hasMatch () ){
254
218
QString username = match.captured (QString (" username" ).toLower ());
255
219
auto reqObj = new OAIUserApiRequest (socket, OAIUserApiApiHandler);
0 commit comments