delphimvcframework/samples/sessions/AppControllerU.pas

55 lines
1.0 KiB
ObjectPascal
Raw Normal View History

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
SessionStop(false);
Render(204, 'No Content');
end;
procedure TApp1MainController.Index(ctx: TWebContext);
begin
ContentType := TMVCMimeType.TEXT_PLAIN;
Render(Session['username']);
end;
end.