Less string concats in router

This commit is contained in:
Daniele Teti 2024-01-25 19:32:04 +01:00
parent 745cf3c24b
commit b42feddffd
3 changed files with 11 additions and 11 deletions

View File

@ -81,7 +81,7 @@ resourcestring
' LServer.ListenQueue := dotEnv.Env(''dmvc.indy.listen_queue'', 500);' + sLineBreak + sLineBreak +
' LServer.Active := True;' + sLineBreak +
' LogI(''Listening on port '' + APort.ToString);' + sLineBreak +
' LogI(''CTRL+C to shutdown the server'');' + sLineBreak +
' LogI(''Application started. Press Ctrl+C to shut down.'');' + sLineBreak +
' WaitForTerminationSignal; ' + sLineBreak +
' EnterInShutdownState; ' + sLineBreak +
' LServer.Active := False; ' + sLineBreak +
@ -174,22 +174,22 @@ resourcestring
sIndexMethodIntf =
' [MVCPath]' + sLineBreak +
' [MVCHTTPMethod([httpGET])]' + sLineBreak +
' procedure Index;' + sLineBreak + sLineBreak +
' function Index: String;' + sLineBreak + sLineBreak +
' [MVCPath(''/reversedstrings/($Value)'')]' + sLineBreak +
' [MVCHTTPMethod([httpGET])]' + sLineBreak +
' [MVCProduces(TMVCMediaType.TEXT_PLAIN)]' + sLineBreak +
' procedure GetReversedString(const Value: String);' + sLineBreak;
' function GetReversedString(const Value: String): String;' + sLineBreak;
// 0 - Class Name
sIndexMethodImpl =
'procedure %0:s.Index;' + sLineBreak +
'function %0:s.Index: String;' + sLineBreak +
'begin' + sLineBreak +
' //use Context property to access to the HTTP request and response ' + sLineBreak +
' Render(''Hello DelphiMVCFramework World'');' + sLineBreak +
' Result := ''Hello DelphiMVCFramework World'';' + sLineBreak +
'end;' + sLineBreak + sLineBreak +
'procedure %0:s.GetReversedString(const Value: String);' + sLineBreak +
'function %0:s.GetReversedString(const Value: String): String;' + sLineBreak +
'begin' + sLineBreak +
' Render(System.StrUtils.ReverseString(Value.Trim));' + sLineBreak +
' Result := System.StrUtils.ReverseString(Value.Trim);' + sLineBreak +
'end;' + sLineBreak;
sCRUDMethodsIntf =

View File

@ -298,7 +298,7 @@ var
begin
AContext.SessionStop(False);
AContext.LoggedUser.Clear;
if not AContext.Request.ThereIsRequestBody then
if not AContext.Request.HasBody then
begin
AHandled := True;
AContext.Response.StatusCode := HTTP_STATUS.BadRequest;

View File

@ -364,7 +364,7 @@ begin
begin
lNames := GetParametersNames(AMVCPath);
lPattern := ToPattern(AMVCPath, lNames);
lCacheItem := TMVCActionParamCacheItem.Create(lPattern, lNames);
lCacheItem := TMVCActionParamCacheItem.Create('^' + lPattern + '$', lNames);
FActionParamsCache.Add(AMVCPath, lCacheItem);
end;
@ -372,12 +372,12 @@ begin
Exit(True)
else
begin
lRegEx := TRegEx.Create('^' + lCacheItem.Value + '$', [roIgnoreCase, roCompiled, roSingleLine]);
lRegEx := TRegEx.Create(lCacheItem.Value, [roIgnoreCase, roCompiled, roSingleLine]);
lMatch := lRegEx.Match(APath);
Result := lMatch.Success;
if Result then
begin
for I := 1 to pred(lMatch.Groups.Count) do
for I := 1 to Pred(lMatch.Groups.Count) do
begin
aParams.Add(lCacheItem.Params[I - 1], TIdURI.URLDecode(lMatch.Groups[I].Value));
end;