Refactor app architecture and clean local artifacts
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
namespace Backend.Common;
|
||||
|
||||
public static class RequestMetadataReader
|
||||
{
|
||||
public static RequestMetadata Read(HttpContext context) =>
|
||||
new(ReadClientIp(context), ReadUserAgent(context));
|
||||
|
||||
public static string ReadClientIp(HttpContext context) =>
|
||||
context.Connection.RemoteIpAddress?.ToString() ?? "unknown";
|
||||
|
||||
public static string ReadUserAgent(HttpContext context)
|
||||
{
|
||||
var value = context.Request.Headers.UserAgent.ToString().Trim();
|
||||
return value.Length > 400 ? value[..400] : value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user