本文整理汇总了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());
}