Skip to content

Commit

Permalink
Improves ApiCenterOnboardingPlugin (#653)
Browse files Browse the repository at this point in the history
Co-authored-by: Garry Trinder <[email protected]>
  • Loading branch information
waldekmastykarz and garrytrinder authored Apr 18, 2024
1 parent 43df5e1 commit f86efe8
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions dev-proxy-plugins/RequestLogs/ApiCenterOnboardingPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,19 @@ private async Task AfterRecordingStop(object sender, RecordingArgs e)
var apiDefinitions = await LoadApiDefinitions(apis.Value);

var newApis = new List<Tuple<string, string>>();
foreach (var request in e.RequestLogs)
var interceptedRequests = e.RequestLogs
.Where(l => l.MessageType == MessageType.InterceptedRequest)
.Select(request => {
var methodAndUrl = request.MessageLines.First().Split(' ');
return new Tuple<string, string>(methodAndUrl[0], methodAndUrl[1]);
})
.Distinct();
foreach (var request in interceptedRequests)
{
if (request.MessageType != MessageType.InterceptedResponse ||
request.Context is null ||
request.Context.Session is null)
{
continue;
}

var methodAndUrlString = request.MessageLines.First();
_logger?.LogDebug("Processing request {methodAndUrl}...", methodAndUrlString);
_logger?.LogDebug("Processing request {method} {url}...", request.Item1, request.Item2);

var methodAndUrl = methodAndUrlString.Split(' ');
var requestMethod = methodAndUrl[0];
var requestUrl = methodAndUrl[1];
var requestMethod = request.Item1;
var requestUrl = request.Item2;

var apiDefinition = apiDefinitions.FirstOrDefault(x => requestUrl.Contains(x.Key)).Value;
if (apiDefinition.Id is null)
Expand Down

0 comments on commit f86efe8

Please sign in to comment.