delphimvcframework/samples/sessions/AppControllerU.pas
daniele.teti 2495c75a61
2014-04-01 17:36:05 +00:00

55 lines
1.0 KiB
ObjectPascal

unit AppControllerU;
interface
uses MVCFramework,
MVCFramework.Logger,
Web.HTTPApp;
type
[MVCPath('/')]
TApp1MainController = class(TMVCController)
public
[MVCPath('/name')]
[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.