Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpGet]
- [Route( "page" )]
- public async Task<IActionResult> GetPage(
- int? page, int? size,
- CancellationToken ct)
- {
- try {
- var response = await _mailService.GetPageAsync( page, size, ct: ct );
- return Respond( response ); // Turn service response into HTTP response
- }
- catch (OperationCanceledException) {
- // When reaching here, Exception already logged
- // If it should be cancelled
- if (ct.IsCancellationRequested) {
- // Empty result
- return new EmptyResult();
- }
- else {
- // Else raise again
- throw; // Never reached
- }
- }
- }
- try {
- page = query.ToListAsync( ct );
- catch(TaskCanceledException){
- // When reaching here, Exception already logged
- return null;
- }
- var logConfig = new LoggerConfiguration()
- .MinimumLevel.Debug()
- .Enrich.FromLogContext();
- // Add Sinks
- // Create Logger
- Log.Logger = logConfig.CreateLogger();
- // Configure()
- loggerFactory.AddSerilog();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement