https://github.com/thinkjs/think-controller
Invoke controller middleware for ThinkJS 3.x
https://github.com/thinkjs/think-controller
controller middleware think-middleware
Last synced: 13 days ago
JSON representation
Invoke controller middleware for ThinkJS 3.x
- Host: GitHub
- URL: https://github.com/thinkjs/think-controller
- Owner: thinkjs
- License: mit
- Created: 2017-03-29T03:37:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-01T15:19:34.000Z (almost 4 years ago)
- Last Synced: 2025-03-22T04:01:52.583Z (29 days ago)
- Topics: controller, middleware, think-middleware
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 5
- Watchers: 11
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- think-awesome - think-controller - johann](https://github.com/toxic-johann) |  |  |  | Invoke controller action | (Middlewares)
README
# think-controller
[](https://travis-ci.org/thinkjs/think-controller)
[](https://coveralls.io/github/thinkjs/think-controller?branch=master)
[](https://www.npmjs.com/package/think-controller)
[](https://david-dm.org/thinkjs/think-controller)Invoke controller for ThinkJS 3.x
## How To Use
Modify src/config/middleware.js:
```js
const controller = require('think-controller');module.exports = [
{
handle: controller,
options: {
emptyModule: '',
emptyController: '',
preSetStatus: 200
}
}
];
```## Options
* `emptyModule` {String} default module when not found
* `emptyController` {String} default controller when not found
* `preSetStatus` {Number} preset http status when action exist
Koa set http status to 404 before request handling, and will changed when set body or status properties. when `preSetStatus` is set and action exist, it's will preset status before action invoked.