Skip to content

Commit

Permalink
mvc: new EMvcApplication raising methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Bouchez committed Jan 16, 2025
1 parent 32de1b0 commit 3417453
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'2.3.9407'
'2.3.9408'
33 changes: 33 additions & 0 deletions src/rest/mormot.rest.mvc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,17 @@ EMvcApplication = class(ESynException)
/// same as calling TMvcApplication.GotoDefault
// - HTTP_TEMPORARYREDIRECT will change the URI, but HTTP_SUCCESS won't
constructor CreateDefault(aStatus: cardinal = HTTP_TEMPORARYREDIRECT);
/// just a wrapper around raise CreateGotoView()
class procedure GotoView(const aMethod: RawUtf8;
const aParametersNameValuePairs: array of const;
aStatus: cardinal = HTTP_TEMPORARYREDIRECT);
/// just a wrapper around raise CreateGotoError()
class procedure GotoError(const aErrorMessage: string;
aErrorCode: integer = HTTP_BADREQUEST); overload;
/// just a wrapper around raise CreateGotoError()
class procedure GotoError(aHtmlErrorCode: integer); overload;
/// just a wrapper around raise CreateDefault()
class procedure Default(aStatus: cardinal = HTTP_TEMPORARYREDIRECT);
end;

/// defines the main and error pages for the ViewModel of one application
Expand Down Expand Up @@ -2249,6 +2260,28 @@ constructor EMvcApplication.CreateGotoView(const aMethod: RawUtf8;
TMvcApplication.GotoView(fAction, aMethod, aParametersNameValuePairs, aStatus);
end;

class procedure EMvcApplication.GotoView(const aMethod: RawUtf8;
const aParametersNameValuePairs: array of const; aStatus: cardinal);
begin
raise CreateGotoView(aMethod, aParametersNameValuePairs, aStatus);
end;

class procedure EMvcApplication.GotoError(const aErrorMessage: string;
aErrorCode: integer);
begin
raise CreateGotoError(aErrorMessage, aErrorCode);
end;

class procedure EMvcApplication.GotoError(aHtmlErrorCode: integer);
begin
raise CreateGotoError(aHtmlErrorCode);
end;

class procedure EMvcApplication.Default(aStatus: cardinal);
begin
raise CreateDefault(aStatus);
end;


{ TMvcApplication }

Expand Down

0 comments on commit 3417453

Please sign in to comment.