Skip to content

Commit 82312c6

Browse files
committed
Sample folders rename. First version of WebStencils SSV engine
1 parent 7863944 commit 82312c6

File tree

832 files changed

+7386
-12864
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

832 files changed

+7386
-12864
lines changed
Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
program ActionFilters;
2-
{$APPTYPE CONSOLE}
3-
4-
5-
uses
6-
System.SysUtils,
7-
MVCFramework.Logger,
8-
Winapi.Windows,
9-
IdHTTPWebBrokerBridge,
10-
Web.WebReq,
11-
Web.WebBroker,
12-
WebModuleU in 'WebModuleU.pas' {WebModule1: TWebModule} ,
13-
ActionFiltersControllerU in 'ActionFiltersControllerU.pas',
14-
BusinessObjectsU in 'BusinessObjectsU.pas';
15-
16-
{$R *.res}
17-
18-
19-
procedure RunServer(APort: Integer);
20-
var
21-
LServer: TIdHTTPWebBrokerBridge;
22-
begin
23-
Writeln(Format('Starting HTTP Server or port %d', [APort]));
24-
LServer := TIdHTTPWebBrokerBridge.Create(nil);
25-
try
26-
LServer.DefaultPort := APort;
27-
LServer.Active := True;
28-
LogI(Format('Server started on port %d', [APort]));
29-
Writeln('Press RETURN to stop the server');
30-
ReadLn;
31-
finally
32-
LServer.Free;
33-
end;
34-
end;
35-
36-
begin
37-
try
38-
if WebRequestHandler <> nil then
39-
WebRequestHandler.WebModuleClass := WebModuleClass;
40-
RunServer(8080);
41-
except
42-
on E: Exception do
43-
Writeln(E.ClassName, ': ', E.Message);
44-
end
45-
46-
end.
1+
program ActionFilters;
2+
{$APPTYPE CONSOLE}
3+
4+
5+
uses
6+
System.SysUtils,
7+
MVCFramework.Logger,
8+
Winapi.Windows,
9+
IdHTTPWebBrokerBridge,
10+
Web.WebReq,
11+
Web.WebBroker,
12+
WebModuleU in 'WebModuleU.pas' {WebModule1: TWebModule} ,
13+
ActionFiltersControllerU in 'ActionFiltersControllerU.pas',
14+
BusinessObjectsU in 'BusinessObjectsU.pas';
15+
16+
{$R *.res}
17+
18+
19+
procedure RunServer(APort: Integer);
20+
var
21+
LServer: TIdHTTPWebBrokerBridge;
22+
begin
23+
Writeln(Format('Starting HTTP Server or port %d', [APort]));
24+
LServer := TIdHTTPWebBrokerBridge.Create(nil);
25+
try
26+
LServer.DefaultPort := APort;
27+
LServer.Active := True;
28+
LogI(Format('Server started on port %d', [APort]));
29+
Writeln('Press RETURN to stop the server');
30+
ReadLn;
31+
finally
32+
LServer.Free;
33+
end;
34+
end;
35+
36+
begin
37+
try
38+
if WebRequestHandler <> nil then
39+
WebRequestHandler.WebModuleClass := WebModuleClass;
40+
RunServer(8080);
41+
except
42+
on E: Exception do
43+
Writeln(E.ClassName, ': ', E.Message);
44+
end
45+
46+
end.

samples/actionfilters/ActionFilters.dproj renamed to samples/action_filters/ActionFilters.dproj

Lines changed: 1186 additions & 1186 deletions
Large diffs are not rendered by default.
Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
1-
unit ActionFiltersControllerU;
2-
3-
interface
4-
5-
uses
6-
MVCFramework, MVCFramework.Commons;
7-
8-
type
9-
10-
[MVCPath('/')]
11-
TActionFiltersController = class(TMVCController)
12-
protected
13-
procedure MVCControllerAfterCreate; override;
14-
procedure MVCControllerBeforeDestroy; override;
15-
16-
procedure OnBeforeAction(Context: TWebContext; const AActionNAme: string;
17-
var Handled: Boolean); override;
18-
procedure OnAfterAction(Context: TWebContext; const AActionNAme: string);
19-
override;
20-
21-
public
22-
[MVCHTTPMethod([httpGet])]
23-
[MVCPath('/people/($id)')]
24-
[MVCProduces('application/json')]
25-
{ This action cannot be called by a browser address bar because requires the
26-
ACCEPT header to be application/json. Use Postman or RAD Studio's RESTDebugger. }
27-
procedure GetPerson(id: Integer);
28-
29-
end;
30-
31-
implementation
32-
33-
uses
34-
System.SysUtils, BusinessObjectsU, Data.DBXJSON, MVCFramework.Logger;
35-
36-
{ TActionFiltersController }
37-
38-
procedure TActionFiltersController.GetPerson(id: Integer);
39-
var
40-
P: TPerson;
41-
begin
42-
{
43-
Use ID to load the person from a database...
44-
In this example, we're creating a fake person
45-
}
46-
P := TPerson.Create;
47-
P.FirstName := 'Daniele';
48-
P.LastName := 'Teti';
49-
P.DOB := EncodeDate(1975, 5, 2);
50-
P.Married := True;
51-
Render(P);
52-
end;
53-
54-
procedure TActionFiltersController.MVCControllerAfterCreate;
55-
begin
56-
inherited;
57-
// raise Exception.Create('Error Message');
58-
Log.Info('MVCControllerAfterCreate', 'ACTIONFILTERS');
59-
end;
60-
61-
procedure TActionFiltersController.MVCControllerBeforeDestroy;
62-
begin
63-
inherited;
64-
end;
65-
66-
procedure TActionFiltersController.OnAfterAction(Context: TWebContext;
67-
const AActionNAme: string);
68-
begin
69-
inherited;
70-
Log.Info('ACTION CALLED: ' + AActionNAme +
71-
' mapped to ' + Context.Request.PathInfo +
72-
' from ' + Context.Request.ClientIP, 'ACTIONFILTERS');
73-
end;
74-
75-
procedure TActionFiltersController.OnBeforeAction(Context: TWebContext;
76-
const AActionNAme: string; var Handled: Boolean);
77-
begin
78-
inherited;
79-
if DayOfWeek(date) in [1, 7] then
80-
raise Exception.Create('You cannot use this service in the WeekEnd');
81-
// if handled = true (or exception raised) then actual action will not be called
82-
end;
83-
84-
end.
1+
unit ActionFiltersControllerU;
2+
3+
interface
4+
5+
uses
6+
MVCFramework, MVCFramework.Commons;
7+
8+
type
9+
10+
[MVCPath('/')]
11+
TActionFiltersController = class(TMVCController)
12+
protected
13+
procedure MVCControllerAfterCreate; override;
14+
procedure MVCControllerBeforeDestroy; override;
15+
16+
procedure OnBeforeAction(Context: TWebContext; const AActionNAme: string;
17+
var Handled: Boolean); override;
18+
procedure OnAfterAction(Context: TWebContext; const AActionNAme: string);
19+
override;
20+
21+
public
22+
[MVCHTTPMethod([httpGet])]
23+
[MVCPath('/people/($id)')]
24+
[MVCProduces('application/json')]
25+
{ This action cannot be called by a browser address bar because requires the
26+
ACCEPT header to be application/json. Use Postman or RAD Studio's RESTDebugger. }
27+
procedure GetPerson(id: Integer);
28+
29+
end;
30+
31+
implementation
32+
33+
uses
34+
System.SysUtils, BusinessObjectsU, Data.DBXJSON, MVCFramework.Logger;
35+
36+
{ TActionFiltersController }
37+
38+
procedure TActionFiltersController.GetPerson(id: Integer);
39+
var
40+
P: TPerson;
41+
begin
42+
{
43+
Use ID to load the person from a database...
44+
In this example, we're creating a fake person
45+
}
46+
P := TPerson.Create;
47+
P.FirstName := 'Daniele';
48+
P.LastName := 'Teti';
49+
P.DOB := EncodeDate(1975, 5, 2);
50+
P.Married := True;
51+
Render(P);
52+
end;
53+
54+
procedure TActionFiltersController.MVCControllerAfterCreate;
55+
begin
56+
inherited;
57+
// raise Exception.Create('Error Message');
58+
Log.Info('MVCControllerAfterCreate', 'ACTIONFILTERS');
59+
end;
60+
61+
procedure TActionFiltersController.MVCControllerBeforeDestroy;
62+
begin
63+
inherited;
64+
end;
65+
66+
procedure TActionFiltersController.OnAfterAction(Context: TWebContext;
67+
const AActionNAme: string);
68+
begin
69+
inherited;
70+
Log.Info('ACTION CALLED: ' + AActionNAme +
71+
' mapped to ' + Context.Request.PathInfo +
72+
' from ' + Context.Request.ClientIP, 'ACTIONFILTERS');
73+
end;
74+
75+
procedure TActionFiltersController.OnBeforeAction(Context: TWebContext;
76+
const AActionNAme: string; var Handled: Boolean);
77+
begin
78+
inherited;
79+
if DayOfWeek(date) in [1, 7] then
80+
raise Exception.Create('You cannot use this service in the WeekEnd');
81+
// if handled = true (or exception raised) then actual action will not be called
82+
end;
83+
84+
end.
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
unit BusinessObjectsU;
2-
3-
interface
4-
5-
type
6-
TPerson = class
7-
private
8-
FLastName: String;
9-
FDOB: TDate;
10-
FFirstName: String;
11-
FMarried: boolean;
12-
procedure SetDOB(const Value: TDate);
13-
procedure SetFirstName(const Value: String);
14-
procedure SetLastName(const Value: String);
15-
procedure SetMarried(const Value: boolean);
16-
public
17-
property FirstName: String read FFirstName write SetFirstName;
18-
property LastName: String read FLastName write SetLastName;
19-
property DOB: TDate read FDOB write SetDOB;
20-
property Married: boolean read FMarried write SetMarried;
21-
end;
22-
23-
implementation
24-
25-
{ TPerson }
26-
27-
procedure TPerson.SetDOB(const Value: TDate);
28-
begin
29-
FDOB := Value;
30-
end;
31-
32-
procedure TPerson.SetFirstName(const Value: String);
33-
begin
34-
FFirstName := Value;
35-
end;
36-
37-
procedure TPerson.SetLastName(const Value: String);
38-
begin
39-
FLastName := Value;
40-
end;
41-
42-
procedure TPerson.SetMarried(const Value: boolean);
43-
begin
44-
FMarried := Value;
45-
end;
46-
47-
end.
1+
unit BusinessObjectsU;
2+
3+
interface
4+
5+
type
6+
TPerson = class
7+
private
8+
FLastName: String;
9+
FDOB: TDate;
10+
FFirstName: String;
11+
FMarried: boolean;
12+
procedure SetDOB(const Value: TDate);
13+
procedure SetFirstName(const Value: String);
14+
procedure SetLastName(const Value: String);
15+
procedure SetMarried(const Value: boolean);
16+
public
17+
property FirstName: String read FFirstName write SetFirstName;
18+
property LastName: String read FLastName write SetLastName;
19+
property DOB: TDate read FDOB write SetDOB;
20+
property Married: boolean read FMarried write SetMarried;
21+
end;
22+
23+
implementation
24+
25+
{ TPerson }
26+
27+
procedure TPerson.SetDOB(const Value: TDate);
28+
begin
29+
FDOB := Value;
30+
end;
31+
32+
procedure TPerson.SetFirstName(const Value: String);
33+
begin
34+
FFirstName := Value;
35+
end;
36+
37+
procedure TPerson.SetLastName(const Value: String);
38+
begin
39+
FLastName := Value;
40+
end;
41+
42+
procedure TPerson.SetMarried(const Value: boolean);
43+
begin
44+
FMarried := Value;
45+
end;
46+
47+
end.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
object WebModule1: TWebModule1
2-
OldCreateOrder = False
3-
OnCreate = WebModuleCreate
4-
Actions = <>
5-
Height = 230
6-
Width = 415
7-
end
1+
object WebModule1: TWebModule1
2+
OldCreateOrder = False
3+
OnCreate = WebModuleCreate
4+
Actions = <>
5+
Height = 230
6+
Width = 415
7+
end

0 commit comments

Comments
 (0)