diff --git a/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt b/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt index fabb7b1e1a..9483473d76 100644 --- a/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt +++ b/src/ServiceControl.Audit.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt @@ -9,7 +9,6 @@ GET /endpoints/{endpoint}/messages/search/{keyword} => ServiceControl.Audit.Audi GET /endpoints/known => ServiceControl.Audit.Monitoring.KnownEndpointsController:GetAll(PagingInfo pagingInfo) GET /instance-info => ServiceControl.Audit.Infrastructure.WebApi.RootController:Config() GET /messages => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:GetAllMessages(PagingInfo pagingInfo, SortInfo sortInfo, Boolean includeSystemMessages) -GET /messages/{*catchAll} => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:CatchAll(String catchAll) GET /messages/{id}/body => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:Get(String id) GET /messages/search => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:Search(PagingInfo pagingInfo, SortInfo sortInfo, String q) GET /messages/search/{keyword} => ServiceControl.Audit.Auditing.MessagesView.GetMessagesController:SearchByKeyWord(PagingInfo pagingInfo, SortInfo sortInfo, String keyword) diff --git a/src/ServiceControl.Audit/Auditing/MessagesView/GetMessagesController.cs b/src/ServiceControl.Audit/Auditing/MessagesView/GetMessagesController.cs index 051123349a..9894835c3d 100644 --- a/src/ServiceControl.Audit/Auditing/MessagesView/GetMessagesController.cs +++ b/src/ServiceControl.Audit/Auditing/MessagesView/GetMessagesController.cs @@ -8,8 +8,6 @@ namespace ServiceControl.Audit.Auditing.MessagesView using Microsoft.AspNetCore.Mvc; using Persistence; - // All routes matching `messages/*` must be in this controller as WebAPI cannot figure out the overlapping routes - // from `messages/{*catchAll}` if they're in separate controllers. [ApiController] [Route("api")] public class GetMessagesController(IAuditDataStore dataStore) : ControllerBase @@ -45,10 +43,7 @@ public async Task> GetEndpointAuditCounts([FromQuery] PagingIn [HttpGet] public async Task Get(string id) { - var messageId = id; - messageId = messageId?.Replace("/", @"\"); - - var result = await dataStore.GetMessageBody(messageId); + var result = await dataStore.GetMessageBody(id); if (result.Found == false) { @@ -62,7 +57,7 @@ public async Task Get(string id) if (result.StringContent == null && result.StreamContent == null) { - throw new Exception($"Metadata for message '{messageId}' indicated that a body was present but no content could be found in storage"); + throw new Exception($"Metadata for message '{id}' indicated that a body was present but no content could be found in storage"); } Response.Headers.ETag = result.ETag; @@ -70,22 +65,6 @@ public async Task Get(string id) return result.StringContent != null ? Content(result.StringContent, contentType) : File(result.StreamContent, contentType); } - // TODO: Verify if this catch all approach is still relevant today with Kestrel - // Possible a message may contain a slash or backslash, either way http.sys will rewrite it to forward slash, - // and then the "normal" route above will not activate, resulting in 404 if this route is not present. - [Route("messages/{*catchAll}")] - [HttpGet] - public async Task CatchAll(string catchAll) - { - if (!string.IsNullOrEmpty(catchAll) && catchAll.EndsWith("/body")) - { - var id = catchAll.Substring(0, catchAll.Length - 5); - return await Get(id); - } - - return NotFound(); - } - [Route("messages/search")] [HttpGet] public async Task> Search([FromQuery] PagingInfo pagingInfo, [FromQuery] SortInfo sortInfo, string q) @@ -99,7 +78,7 @@ public async Task> Search([FromQuery] PagingInfo pagingInfo, [HttpGet] public async Task> SearchByKeyWord([FromQuery] PagingInfo pagingInfo, [FromQuery] SortInfo sortInfo, string keyword) { - var result = await dataStore.QueryMessages(keyword?.Replace("/", @"\"), pagingInfo, sortInfo); + var result = await dataStore.QueryMessages(keyword, pagingInfo, sortInfo); Response.WithQueryStatsAndPagingInfo(result.QueryStats, pagingInfo); return result.Results; } diff --git a/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt b/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt index d9f1fdbc10..114ee259b0 100644 --- a/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt +++ b/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt @@ -40,7 +40,6 @@ GET /heartbeats/stats => ServiceControl.Monitoring.EndpointsMonitoringController GET /instance-info => ServiceControl.Infrastructure.WebApi.RootController:Config() GET /license => ServiceControl.Licensing.LicenseController:License(Boolean refresh) GET /messages => ServiceControl.CompositeViews.Messages.GetMessagesController:Messages(PagingInfo pagingInfo, SortInfo sortInfo, Boolean includeSystemMessages) -GET /messages/{*catchAll} => ServiceControl.CompositeViews.Messages.GetMessagesController:CatchAll(String catchAll, String instanceId) GET /messages/{id}/body => ServiceControl.CompositeViews.Messages.GetMessagesController:Get(String id, String instanceId) GET /messages/search => ServiceControl.CompositeViews.Messages.GetMessagesController:Search(PagingInfo pagingInfo, SortInfo sortInfo, String q) GET /messages/search/{keyword} => ServiceControl.CompositeViews.Messages.GetMessagesController:SearchByKeyWord(PagingInfo pagingInfo, SortInfo sortInfo, String keyword) diff --git a/src/ServiceControl/CompositeViews/Messages/GetMessagesController.cs b/src/ServiceControl/CompositeViews/Messages/GetMessagesController.cs index ccd18aa840..c3371d8ef5 100644 --- a/src/ServiceControl/CompositeViews/Messages/GetMessagesController.cs +++ b/src/ServiceControl/CompositeViews/Messages/GetMessagesController.cs @@ -87,22 +87,6 @@ public async Task Get(string id, [FromQuery(Name = "instance_id") return Empty; } - // TODO Is this still needed? - // Possible a message may contain a slash or backslash, either way http.sys will rewrite it to forward slash, - // and then the "normal" route above will not activate, resulting in 404 if this route is not present. - [Route("messages/{*catchAll}")] - [HttpGet] - public async Task CatchAll(string catchAll, [FromQuery(Name = "instance_id")] string instanceId) - { - if (!string.IsNullOrEmpty(catchAll) && catchAll.EndsWith("/body")) - { - var id = catchAll[..^5]; - return await Get(id, instanceId); - } - - return NotFound(); - } - [Route("messages/search")] [HttpGet] public Task> Search([FromQuery] PagingInfo pagingInfo, [FromQuery] SortInfo sortInfo, string q) => api.Execute(new(pagingInfo, sortInfo, q));