mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
fix: remove broken ping endpoint and improve error handling
- Remove custom /ping endpoint that returned non-standard JSON format - Fix wildcard endpoint to return Subsonic-compatible error responses - All requests now properly relay to/from the real Subsonic server
This commit is contained in:
@@ -88,17 +88,6 @@ public class SubsonicController : ControllerBase
|
|||||||
return (body, contentType);
|
return (body, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet, HttpPost]
|
|
||||||
[Route("ping")]
|
|
||||||
public async Task<IActionResult> Ping()
|
|
||||||
{
|
|
||||||
var parameters = await ExtractAllParameters();
|
|
||||||
var xml = await RelayToSubsonic("ping", parameters);
|
|
||||||
var doc = XDocument.Parse((string)xml.Body);
|
|
||||||
var status = doc.Root?.Attribute("status")?.Value;
|
|
||||||
return Ok(new { status });
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Endpoint search3 personnalisé - fusionne les résultats locaux et externes
|
/// Endpoint search3 personnalisé - fusionne les résultats locaux et externes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -755,15 +744,18 @@ public class SubsonicController : ControllerBase
|
|||||||
public async Task<IActionResult> GenericEndpoint(string endpoint)
|
public async Task<IActionResult> GenericEndpoint(string endpoint)
|
||||||
{
|
{
|
||||||
var parameters = await ExtractAllParameters();
|
var parameters = await ExtractAllParameters();
|
||||||
|
var format = parameters.GetValueOrDefault("f", "xml");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await RelayToSubsonic(endpoint, parameters);
|
var result = await RelayToSubsonic(endpoint, parameters);
|
||||||
var contentType = result.ContentType ?? $"application/{parameters.GetValueOrDefault("f", "xml")}";
|
var contentType = result.ContentType ?? $"application/{format}";
|
||||||
return File((byte[])result.Body, contentType);
|
return File((byte[])result.Body, contentType);
|
||||||
}
|
}
|
||||||
catch (HttpRequestException ex)
|
catch (HttpRequestException ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new { error = $"Error while calling Subsonic: {ex.Message}" });
|
// Return Subsonic-compatible error response
|
||||||
|
return CreateSubsonicError(format, 0, $"Error connecting to Subsonic server: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user