本文整理汇总了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);
}