添加headerapi

This commit is contained in:
2025-02-26 08:07:32 +08:00
parent 1a7bdb585a
commit 1fa5e0c037
3 changed files with 14 additions and 6 deletions

View File

@@ -6,10 +6,15 @@ namespace MegghysAPI.Controllers
[ApiController]
public class PublicController : MControllerBase
{
[Route("header")]
public IActionResult Header()
[HttpGet("header")]
public IActionResult Header(bool? order = false)
{
return Ok(string.Join(",", context.Request.Headers.Keys));
var headers = Request.Headers.Select(h => $"{h.Key}: {h.Value}");
if (order == true)
{
headers = headers.OrderBy(h => h);
}
return Ok(string.Join(Environment.NewLine, headers));
}
}
}