像这样.
import { RouteGroup, get } from 'vio';
// extends `RouteGroup` class.
export default class Default extends RouteGroup {
// route as a HTTP GET request.
@get()
static default() {
// can also be a promise if it's async.
return {
title: 'Hello, VIO!',
content: 'Keep calm and read the source code.'
};
}
}
当然, 也可以做 JSON API 使用.
Feel terrible inside some logic? Throw an error!