Skip to content

Commit

Permalink
Update examples.md (#2862)
Browse files Browse the repository at this point in the history
以下是webman中的response助手函数
/**
 * Response
 * @param int $status
 * @param array $headers
 * @param string $body
 * @return Response
 */
function response(string $body = '', int $status = 200, array $headers = []): Response
{
    return new Response($status, $headers, $body);
}
其中$body类型约束为string,这样改后是不是更规范一些。
  • Loading branch information
pengxuxu authored Dec 3, 2024
1 parent 40662a0 commit e117f57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/src/6.x/official-account/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class OfficialAccount
$server = $app->getServer();
$response = $server->serve();

return response($response->getBody());
return response($response->getBody()->getContents(), $response->getStatusCode(), $response->getHeaders());
}
}
```
Expand Down Expand Up @@ -71,7 +71,7 @@ class OfficialAccountController
}

if (method_exists($app, 'setCache')) {
$app->setCache(ApplicationContext::getContainer()->get(CacheInterface::class) //可选,根据实际需求替换缓存
$app->setCache(ApplicationContext::getContainer()->get(CacheInterface::class)); //可选,根据实际需求替换缓存
}

$server = $app->getServer();
Expand Down

0 comments on commit e117f57

Please sign in to comment.