From 8f4880d7ad2c793c451dc80dc9a35adb37bb0f3c Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sat, 29 Oct 2022 14:48:02 -0500 Subject: AƱadidos filters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Filters/ActionFilter.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Filters/ActionFilter.cs (limited to 'Filters/ActionFilter.cs') diff --git a/Filters/ActionFilter.cs b/Filters/ActionFilter.cs new file mode 100644 index 0000000..002adda --- /dev/null +++ b/Filters/ActionFilter.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc; + +namespace LibraryAPI.Filters { + public class ActionFilter : IActionFilter { + private readonly ILogger log; + + public ActionFilter(ILogger log) { + this.log = log; + } + + public void OnActionExecuting(ActionExecutingContext context) { + string log_string = $@"Got request {context.HttpContext.Request.Method} {context.HttpContext.Request.Path}"; + log.LogInformation("Before Action\n" + log_string); + } + + public void OnActionExecuted(ActionExecutedContext context) { + log.LogInformation("After Action"); + } + } +} -- cgit v1.2.3