本文整理匯總了PHP中Slim\Slim::etag方法的典型用法代碼示例。如果您正苦於以下問題:PHP Slim::etag方法的具體用法?PHP Slim::etag怎麽用?PHP Slim::etag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Slim\Slim
的用法示例。
在下文中一共展示了Slim::etag方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addRouteDefinitions
/**
* This methods will be called at application startup
* @param $appInstance
* @return void
* @throws \Exception
*/
public static function addRouteDefinitions(Slim $appInstance)
{
$appInstance->map('/protected-storage/:inst/:id/:accessMethod/:path+', function ($inst, $id, $accessMethod, $path) use($appInstance) {
if (!in_array($accessMethod, cProtectedStorage::$allowedAccessMethods, true)) {
$appInstance->halt(400, 'Invalid request');
}
$fileName = array_pop($path);
$rel = '';
foreach ($path as $value) {
$rel .= $value . '/';
}
$rel .= $fileName;
$user = null;
if ($accessMethod === 'private') {
try {
$user = new MembersAuth();
$user->isUserLoggedIn();
} catch (LoginExceptions $e) {
$appInstance->halt(401, 'Unauthorized');
}
}
$fullPath = $inst . '/' . $id . '/' . $accessMethod . '/' . $rel;
$controller = new cProtectedStorage($inst, $id, $accessMethod, $rel);
if ($controller->isCorrectPath($fullPath)) {
$appInstance->etag(md5($fullPath));
$appInstance->expires('+1 week');
$headers = $controller->outputFile();
if (array_key_exists('download', $_REQUEST)) {
$headers['Content-Type'] = 'application/octet-stream';
}
foreach ($headers as $key => $value) {
$appInstance->response->headers->set($key, $value);
}
} else {
$appInstance->notFound();
}
})->via('GET', 'POST');
}
示例2: responseStatus
public function responseStatus()
{
$this->_app->etag(md5($this->_app->response->getBody()));
$this->_app->getLog()->debug('Response status: ' . $this->_app->response->getStatus());
}