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

namespace WhatApi.Endpoints;

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