Migrate to new tribufu project structure (#2)

* Migrate to new tribufu project structure

* Update .gitignore

* Remove old api files

* Update Directory.Build.props

* Rename solution
This commit is contained in:
Guilherme Werner 2026-06-21 12:27:05 -03:00 committed by GitHub
parent be25ee8fe3
commit 7e8e192dc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
115 changed files with 41 additions and 262 deletions

View file

@ -1,33 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: UNLICENSED
using Microsoft.AspNetCore.Http;
using System;
using System.Linq;
namespace Tribufu.AspNetCore.Extensions
{
public static class HttpContextExtensions
{
public static string GetIpAddress(this HttpContext context)
{
var headers = context.Request.Headers;
if (headers.TryGetValue("CF-Connecting-IP", out var cfConnectingIp))
{
return cfConnectingIp.FirstOrDefault() ?? "127.0.0.1";
}
if (headers.TryGetValue("X-Forwarded-For", out var xForwardedFor))
{
var forwardedIps = xForwardedFor.ToString().Split(',', StringSplitOptions.RemoveEmptyEntries);
if (forwardedIps.Length > 0)
{
return forwardedIps[0].Trim();
}
}
return context.Connection.RemoteIpAddress?.ToString() ?? "127.0.0.1";
}
}
}