mirror of
https://github.com/Megghy/MegghysAPI.git
synced 2025-12-06 22:26:56 +08:00
添加headerapi
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user