public async Task Invoke(IDictionary <string, object> environment) { IEncoding compression = SelectCompression(environment); if (compression == null) { await _next(environment); return; } ICompressedStorage storage = GetStorage(environment); if (storage == null) { await _next(environment); return; } var context = new StaticCompressionContext(environment, _options, compression, storage); context.Attach(); try { await _next(environment); await context.Complete(); } catch (Exception) { context.Detach(); throw; } }
public async Task Invoke(IDictionary<string, object> environment) { IEncoding compression = SelectCompression(environment); if (compression == null) { await _next(environment); return; } ICompressedStorage storage = GetStorage(environment); if (storage == null) { await _next(environment); return; } var context = new StaticCompressionContext(environment, _options, compression, storage); context.Attach(); try { await _next(environment); await context.Complete(); } catch (Exception) { context.Detach(); throw; } }
public Task Invoke(IDictionary<string, object> environment) { IEncoding compression = SelectCompression(environment); if (compression == null) { return _next(environment); } ICompressedStorage storage = GetStorage(environment); if (storage == null) { return _next(environment); } var context = new StaticCompressionContext(environment, _options, compression, storage); context.Attach(); return _next(environment) .Then((Func<Task>)context.Complete) .Catch(context.Complete); }
public Task Invoke(IDictionary <string, object> environment) { IEncoding compression = SelectCompression(environment); if (compression == null) { return(_next(environment)); } ICompressedStorage storage = GetStorage(environment); if (storage == null) { return(_next(environment)); } var context = new StaticCompressionContext(environment, _options, compression, storage); context.Attach(); return(_next(environment) .Then((Func <Task>)context.Complete) .Catch(context.Complete)); }