1
0
Fork 0

Foxx: Added the same for onlyIf and onlyIfAuthenticated

This commit is contained in:
Lucas Dohmen 2013-09-09 12:20:28 +02:00
parent 3e033be395
commit 7a7d972069
2 changed files with 51 additions and 1 deletions

View File

@ -191,6 +191,14 @@ The following methods are available:
@copydetails JSF_foxx_RequestContextBuffer_errorResponse
### onlyIf
@copydetails JSF_foxx_RequestContextBuffer_onlyIf
### onlyIfAuthenticated
@copydetails JSF_foxx_RequestContextBuffer_onlyIfAuthenticated
Before and After Hooks
----------------------

View File

@ -389,7 +389,49 @@ _.each([
/// });
/// @endcode
////////////////////////////////////////////////////////////////////////////////
"errorResponse"
"errorResponse",
////////////////////////////////////////////////////////////////////////////////
/// @fn JSF_foxx_RequestContextBuffer_onlyIf
/// @brief Defines a controller-wide onlyIf
///
/// @FUN{RequestContextBuffer::onlyIf(@FA{code}, @FA{reason})}
///
/// Defines an `onlyIf` for all routes of this controller. For details on
/// `onlyIf` see the according method on routes.
///
/// @EXAMPLES
///
/// @code
/// app.allroutes.onlyIf(myPersonalCheck);
///
/// app.get("/foxx", function {
/// // Do something
/// });
/// @endcode
////////////////////////////////////////////////////////////////////////////////
"onlyIf",
////////////////////////////////////////////////////////////////////////////////
/// @fn JSF_foxx_RequestContextBuffer_onlyIfAuthenticated
/// @brief Defines a controller-wide onlyIfAuthenticated
///
/// @FUN{RequestContextBuffer::errorResponse(@FA{errorClass}, @FA{code}, @FA{description})}
///
/// Defines an `onlyIfAuthenticated` for all routes of this controller. For details on
/// `onlyIfAuthenticated` see the according method on routes.
///
/// @EXAMPLES
///
/// @code
/// app.allroutes.onlyIfAuthenticated(401, "You need to be authenticated");
///
/// app.get("/foxx", function {
/// // Do something
/// });
/// @endcode
////////////////////////////////////////////////////////////////////////////////
"onlyIfAuthenticated"
], function(functionName) {
extend(RequestContextBuffer.prototype[functionName] = function () {
this.applyChain.push({