summaryrefslogtreecommitdiff
path: root/Filters
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2022-10-29 14:48:02 -0500
committerHombreLaser <sebastian-440@live.com>2022-10-29 14:48:02 -0500
commit8f4880d7ad2c793c451dc80dc9a35adb37bb0f3c (patch)
tree9e1e72aa162181404f31c46eeb4ca2d9e0ce1ed6 /Filters
parentaa37e431b0ec0c87d8f03c211aa73e1f186f1305 (diff)
Añadidos filters
Diffstat (limited to 'Filters')
-rw-r--r--Filters/ActionFilter.cs21
1 files changed, 21 insertions, 0 deletions
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<ActionFilter> log;
+
+ public ActionFilter(ILogger<ActionFilter> 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");
+ }
+ }
+}