summaryrefslogtreecommitdiff
path: root/Filters
diff options
context:
space:
mode:
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");
+ }
+ }
+}