mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 03:38:16 +08:00
Added request id functionality and general refactoring..also turned out i wasnt returning headers....sigh
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
@ -26,6 +27,7 @@ namespace Ocelot.AcceptanceTests
|
||||
private HttpContent _postContent;
|
||||
private BearerToken _token;
|
||||
public HttpClient OcelotClient => _ocelotClient;
|
||||
public string RequestIdKey = "OcRequestId";
|
||||
|
||||
public void GivenThereIsAConfiguration(YamlConfiguration yamlConfiguration)
|
||||
{
|
||||
@ -146,6 +148,13 @@ namespace Ocelot.AcceptanceTests
|
||||
_response = _ocelotClient.GetAsync(url).Result;
|
||||
}
|
||||
|
||||
public void WhenIGetUrlOnTheApiGateway(string url, string requestId)
|
||||
{
|
||||
_ocelotClient.DefaultRequestHeaders.TryAddWithoutValidation(RequestIdKey, requestId);
|
||||
|
||||
_response = _ocelotClient.GetAsync(url).Result;
|
||||
}
|
||||
|
||||
public void WhenIPostUrlOnTheApiGateway(string url)
|
||||
{
|
||||
_response = _ocelotClient.PostAsync(url, _postContent).Result;
|
||||
@ -171,5 +180,15 @@ namespace Ocelot.AcceptanceTests
|
||||
_ocelotClient?.Dispose();
|
||||
_ocelotServer?.Dispose();
|
||||
}
|
||||
|
||||
public void ThenTheRequestIdIsReturned()
|
||||
{
|
||||
_response.Headers.GetValues(RequestIdKey).First().ShouldNotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
public void ThenTheRequestIdIsReturned(string expected)
|
||||
{
|
||||
_response.Headers.GetValues(RequestIdKey).First().ShouldBe(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user