refactoring for integration
This commit is contained in:
parent
80144bf9fc
commit
070f41ac7e
48 changed files with 100 additions and 46 deletions
28
src/Yavsc.Api/Helpers/RequestHelpers.cs
Normal file
28
src/Yavsc.Api/Helpers/RequestHelpers.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.ViewModels;
|
||||
using Yavsc.Models;
|
||||
using System.Linq;
|
||||
|
||||
namespace Yavsc.Api.Helpers
|
||||
{
|
||||
public static class RequestHelpers
|
||||
{
|
||||
// Check for some apache proxy header, if any
|
||||
public static string? ForwardedFor(this HttpRequest request) {
|
||||
string? host = request.Headers["X-Forwarded-For"];
|
||||
if (string.IsNullOrEmpty(host)) {
|
||||
host = request.Host.Value;
|
||||
} else { // Using X-Forwarded-For last address
|
||||
host = host.Split(',')
|
||||
.Last()
|
||||
.Trim();
|
||||
}
|
||||
return host;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue