2014-04-01 00:02:31 +02:00
|
|
|
unit AppControllerU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses MVCFramework,
|
|
|
|
MVCFramework.Logger,
|
|
|
|
Web.HTTPApp;
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
[MVCPath('/')]
|
|
|
|
TApp1MainController = class(TMVCController)
|
|
|
|
public
|
2014-04-01 19:36:05 +02:00
|
|
|
[MVCPath('/name')]
|
2014-04-01 00:02:31 +02:00
|
|
|
[MVCHTTPMethod([httpGET])]
|
|
|
|
procedure Index(ctx: TWebContext);
|
|
|
|
|
|
|
|
[MVCPath('/login/($username)')]
|
|
|
|
[MVCHTTPMethod([httpGET])]
|
|
|
|
procedure DoLogin(ctx: TWebContext);
|
|
|
|
|
|
|
|
[MVCPath('/logout')]
|
|
|
|
[MVCHTTPMethod([httpGET])]
|
|
|
|
procedure DoLogout(ctx: TWebContext);
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
Data.DBXJSON,
|
|
|
|
System.SysUtils, MVCFramework.Commons;
|
|
|
|
|
|
|
|
{ TApp1MainController }
|
|
|
|
|
|
|
|
procedure TApp1MainController.DoLogin(ctx: TWebContext);
|
|
|
|
begin
|
|
|
|
Session['username'] := ctx.Request.Params['username'];
|
|
|
|
Render(204, 'No Content');
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TApp1MainController.DoLogout(ctx: TWebContext);
|
|
|
|
begin
|
2016-05-03 19:04:24 +02:00
|
|
|
ctx.SessionStop(false);
|
2014-04-01 00:02:31 +02:00
|
|
|
Render(204, 'No Content');
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TApp1MainController.Index(ctx: TWebContext);
|
|
|
|
begin
|
2016-01-01 23:00:22 +01:00
|
|
|
ContentType := TMVCMediaType.TEXT_PLAIN;
|
2014-04-01 00:02:31 +02:00
|
|
|
Render(Session['username']);
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|