Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions source/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,8 @@ hexo.extend.filter.register("after_clean", function () {

Add middleware to the server. `app` is a [Connect] instance.

For example, to add `X-Powered-By: Hexo` to the response header:

```js
hexo.extend.filter.register("server_middleware", function (app) {
app.use(function (req, res, next) {
res.setHeader("X-Powered-By", "Hexo");
next();
});
});
```
This hook is provided by [hexo-server], not Hexo core, so it only runs when `hexo-server` is installed. See the [hexo-server README] for an implementation example.

[Connect]: https://github.com/senchalabs/connect
[hexo-server]: https://github.com/hexojs/hexo-server
[hexo-server README]: https://github.com/hexojs/hexo-server#middleware

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Point the README link at an existing example

The new note sends readers to https://github.com/hexojs/hexo-server#middleware, but I checked the linked hexo-server README on master and it only has Installation, Usage, Options, and License headings, so the #middleware anchor does not exist and there is no implementation example there. When users follow this documentation they land on the top of the README without the promised server_middleware guidance; this should either keep the example here or link to a committed page/PR once that Middleware section exists.

Useful? React with 👍 / 👎.