📅  最后修改于: 2022-03-11 14:48:25.488000             🧑  作者: Mango
import {inject, intercept, Interceptor} from '@loopback/context';
import {get, HttpErrors, RestBindings} from '@loopback/rest';
const myInterceptor: Interceptor = async (invocationCtx, next) => {
// your code
// goes here
// if success
next()
// if error
throw new HttpErrors.NotFound();
};
export class PingController {
constructor() {}
@intercept(myInterceptor)
@post('/test')
async test(@requestBody() body: any) {
// some code
}
}