本文整理匯總了TypeScript中restify.acceptParser函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript acceptParser函數的具體用法?TypeScript acceptParser怎麽用?TypeScript acceptParser使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了acceptParser函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor(name: string) {
this.router = Restify.createServer({
name: name
});
this.router.on('listening', () => {
log.debug(`${this.router.name} listening on ${this.router.url}`);
});
this.router.use(Restify.acceptParser(this.router.acceptable));
this.router.use(stripEmptyBearerToken);
this.router.use(Restify.dateParser());
this.router.use(Restify.queryParser());
}
示例2: bootstrap
public bootstrap(port: number) {
this.restifyApplication.use(restify.CORS());
this.restifyApplication.use(restify.pre.sanitizePath());
this.restifyApplication.use(restify.acceptParser(this.restifyApplication.acceptable));
this.restifyApplication.use(restify.bodyParser());
this.restifyApplication.use(restify.queryParser());
this.restifyApplication.use(restify.authorizationParser());
this.restifyApplication.use(restify.fullResponse());
// configure API and error routes
this.restifyContactRouter.configApiRoutes(this.restifyApplication);
this.restifyContactRouter.configErrorRoutes(this.restifyApplication);
// listen on provided ports
this.restifyApplication.listen(port, () => {
console.log("%s listening at %s", this.restifyApplication.name, this.restifyApplication.url);
});
}
示例3: function
import * as restify from "restify";
import * as routes from "./routes";
//config
export const server = restify.createServer({
name: 'myAPI',
version: '1.0.0'
});
//parsing settings
server.use(restify.acceptParser(server.acceptable));
server.use(restify.queryParser());
server.use(restify.bodyParser());
server.pre(restify.pre.sanitizePath());
//call the routes.ts file for available REST API routes
console.log('setting routes...');
routes.setRoutes(server);
//when running the app will listen locally to port 51234
server.listen(51234, function() {
console.log('%s listening at %s', server.name, server.url);
})