Skip to content

Commit

Permalink
Functional Actions Sample Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed May 23, 2024
1 parent 9edc977 commit fcee922
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
29 changes: 23 additions & 6 deletions samples/functional_actions_showcase/ControllerU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TMyController = class(TMVCController)
[MVCPath('/headers')]
function GetWithCustomHeaders: TObjectList<TPerson>;

{ using IMVCResponse }
{ using IMVCResponse and Response Methods}
[MVCPath('/mvcresponse/message')]
function GetMVCResponseSimple: IMVCResponse;
[MVCPath('/mvcresponse/data')]
Expand All @@ -84,9 +84,14 @@ TMyController = class(TMVCController)
function GetMVCResponseSimpleBuilderWithHeaders: IMVCResponse;
[MVCPath('/mvcresponse/message/builder/nobody')]
function GetMVCResponseNoBody: IMVCResponse;
// Standard Responses
[MVCPath('/mvcresponse/ok')]
function GetOKResponse: IMVCResponse;
[MVCPath('/mvcresponse/not_found')]
function GetNotFound: IMVCResponse;
[MVCPath('/mvcresponse/not_modified')]
function GetNotModified: IMVCResponse;
[MVCPath('/mvcresponse/accepted')]
function GetAccepted: IMVCResponse;
end;

implementation
Expand Down Expand Up @@ -148,10 +153,7 @@ function TMyController.GetMVCResponseNoBody: IMVCResponse;

function TMyController.GetMVCResponseSimple: IMVCResponse;
begin
Result := MVCResponseBuilder
.StatusCode(HTTP_STATUS.OK)
.Body('My Message')
.Build;
Result := OKResponse('My Message');
end;

function TMyController.GetMVCResponseSimpleBuilderWithHeaders: IMVCResponse;
Expand Down Expand Up @@ -209,6 +211,16 @@ function TMyController.GetMVCResponseWithObjectList: IMVCResponse;
]));
end;

function TMyController.GetNotFound: IMVCResponse;
begin
Result := NotFoundResponse;
end;

function TMyController.GetNotModified: IMVCResponse;
begin
Result := NotModifiedResponse;
end;

function TMyController.GetOKResponse: IMVCResponse;
begin
Result := OKResponse;
Expand Down Expand Up @@ -270,6 +282,11 @@ function TMyController.GetSumAsFloat(const A, B: Extended): Extended;
Result := A + B;
end;

function TMyController.GetAccepted: IMVCResponse;
begin
Result := AcceptedResponse('https://www.danieleteti.it');
end;

function TMyController.GetConcatAsString(const A, B: String): String;
begin
Result := A + B;
Expand Down
15 changes: 0 additions & 15 deletions samples/functional_actions_showcase/function_actions_showcase.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,6 @@ begin
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;

dotEnvConfigure(
function: IMVCDotEnv
begin
Result := NewDotEnv
.UseStrategy(TMVCDotEnvPriority.FileThenEnv)
//if available, by default, loads default environment (.env)
.UseProfile('test') //if available loads the test environment (.env.test)
.UseProfile('prod') //if available loads the prod environment (.env.prod)
.UseLogger(procedure(LogItem: String)
begin
LogW('dotEnv: ' + LogItem);
end)
.Build(); //uses the executable folder to look for .env* files
end);

WebRequestHandlerProc.MaxConnections := dotEnv.Env('dmvc.handler.max_connections', 1024);
RunServer(dotEnv.Env('dmvc.server.port', 8080));
except
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Console</AppType>
<MainSource>function_actions_showcase.dpr</MainSource>
<ProjectName Condition="'$(ProjectName)'==''">function_actions_showcase</ProjectName>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
Expand Down Expand Up @@ -761,6 +762,9 @@
<Platform Name="Win64">
<Operation>1</Operation>
</Platform>
<Platform Name="Win64x">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice32">
Expand Down Expand Up @@ -1021,6 +1025,7 @@
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64x" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Android">False</Platform>
Expand Down

0 comments on commit fcee922

Please sign in to comment.