using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace HT.Cloud.Web { /// /// 测试文件 /// [Route("api/[controller]/[action]")] [ApiExplorerSettings(GroupName = "V2")] [ApiController] [LoginFilter] public class TestController : ControllerBase { // GET: api/ [HttpGet] public IEnumerable Get() { return new string[] { "value1", "value2" }; } // GET api//5 [HttpGet("{id}")] public string Get(int id) { return "value"; } // POST api/ [HttpPost] public void Post([FromBody, Required(ErrorMessage = "值不能为空")] string value) { } // PUT api//5 [HttpPut("{id}")] public void Put(int id, [FromBody, Required(ErrorMessage = "值不能为空")] string value) { } // DELETE api//5 [HttpDelete("{id}")] public void Delete(int id) { } } }