本文整理匯總了TypeScript中@jonggrang/wai.createHttpContext函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createHttpContext函數的具體用法?TypeScript createHttpContext怎麽用?TypeScript createHttpContext使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了createHttpContext函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('return disl storage if content-length greater than 50000', () => {
const req = {
headers: {
'content-length': 80000
}
};
const storage = defaultGetStorage(createHttpContext(req as any));
assert.ok(storage instanceof DiskStorage);
});
示例2: it
it('should process x-www-form-urlencoded', async function () {
const req = new PassThrough();
req.end('name=foo&key=value&abc=xyz');
(req as any).headers = {
'content-type': 'application/x-www-form-urlencoded',
'content-length': 26
};
(req as any).method = 'GET';
(req as any).url = '/upload';
const ctx = W.createHttpContext(req as any);
await T.toPromise(middleware(simpleApp)(ctx, T.pure));
assert.deepEqual(ctx.state.body, {
name: 'foo',
key: 'value',
abc: 'xyz'
});
});
示例3: mutter
(form as any).getLength((err: Error | null, len: number) => {
if (err) return cb(err);
const app = mutter(simpleApp);
const request = new PassThrough();
(request as any).complete = false;
form.once('end', () => {
(request as any).complete = true;
});
form.pipe(request);
(request as any).headers = {
'content-type': 'multipart/form-data; boundary=' + (form as any).getBoundary(),
'content-length': len
};
const ctx: W.HttpContext = W.createHttpContext(request as any);
T.runTask(app(ctx, T.pure), err => {
if (err) return cb(err);
cb(null, ctx);
});
});
示例4: request
function request(app: Application, req: IncomingMessageMock): T.Task<Response> {
return app(createHttpContext(req as any), T.pure);
}