41 lines
983 B
C#
41 lines
983 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace WarhoundConsole
|
|
{
|
|
[ApiController]
|
|
[Route("api/test")]
|
|
public class Test : ControllerBase
|
|
{
|
|
[HttpGet("hello")]
|
|
public ActionResult<string> GetGreeting()
|
|
{
|
|
string message = "Hello!!!";
|
|
if (message.Length != 0)
|
|
{
|
|
//throw new Exception("Hello");
|
|
}
|
|
return Ok(message);
|
|
}
|
|
|
|
[HttpGet("data")]
|
|
public ActionResult<object> GetData()
|
|
{
|
|
var data = new { Id = 1, Name = "Sample Data", Timestamp = DateTime.UtcNow };
|
|
return Ok(data);
|
|
}
|
|
|
|
[HttpPost("json")]
|
|
public ActionResult<object> asd([FromBody] object obj)
|
|
{
|
|
//if (obj == null)
|
|
//{
|
|
// return BadRequest("Invalid data.");
|
|
//}
|
|
|
|
Console.Write(obj.ToString());
|
|
|
|
return Ok(new { a = 1, b = 2, c = "c" });
|
|
}
|
|
}
|
|
}
|