Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindRequestByMappingGuidAsync #1043

Merged
merged 3 commits into from
Dec 21, 2023
Merged

FindRequestByMappingGuidAsync #1043

merged 3 commits into from
Dec 21, 2023

Conversation

StefH
Copy link
Collaborator

@StefH StefH commented Dec 16, 2023

No description provided.

@StefH StefH added the feature label Dec 16, 2023
@StefH StefH self-assigned this Dec 16, 2023
@StefH StefH merged commit a8339a0 into master Dec 21, 2023
7 of 9 checks passed
@StefH StefH deleted the stef-1039-find-request branch December 21, 2023 19:03
Copy link
Contributor

@tlevesque-ueat tlevesque-ueat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review comes a bit late, sorry about that... I didn't pay enough attention when you first sent the PR.
I realize changing it now would be a breaking change, but I think it's worth it, because at the moment it's broken (it will throw if there's more than one matching request)

/// <param name="mappingGuid">The Mapping Guid</param>
/// <param name="cancellationToken">The optional cancellationToken.</param>
[Get("requests/find")]
Task<LogEntryModel?> FindRequestByMappingGuidAsync([Query] Guid mappingGuid, CancellationToken cancellationToken = default);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be FindRequestsByMappingGuidAsync, and return a collection

Guid.TryParse(value.ToString(), out var mappingGuid)
)
{
var logEntry = LogEntries.SingleOrDefault(le => !le.RequestMessage.Path.StartsWith("/__admin/") && le.MappingGuid == mappingGuid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be more than one matching request, and in this case SingleOrDefault will throw.

return ToJson(logEntryMapper.Map(logEntry));
}

return ResponseMessageBuilder.Create(HttpStatusCode.OK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning 200 with an empty response is probably not what the client would expect. If the status code is 200, the client will expect the body to contain a LogEntryModel.

But anyway, I think this endpoint should return a collection (which will be empty if no match is found)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants