summaryrefslogtreecommitdiffstats
path: root/api/WhatApi/Endpoints/BaseEndpoint.cs
blob: 0820ac1b5236c4a1ed8351892470d980abc07913 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
using System.Net;

namespace WhatApi.Endpoints;

[Authorize]
[ApiController]
public class BaseEndpoint : ControllerBase
{
    protected IPAddress GetIp() => Request.Headers.TryGetValue("X-Forwarded-For", out var ip)
        ? IPAddress.Parse(ip.ToString())
        : HttpContext.Connection.RemoteIpAddress!;
}