간단한 API 테스트
This commit is contained in:
40
WarhoundConsole/Test.cs
Normal file
40
WarhoundConsole/Test.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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" });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user