HttpTest.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Net;
  2. using ETModel;
  3. using System.Threading.Tasks;
  4. namespace ETHotfix
  5. {
  6. [HttpHandler(AppType.Gate, "/")]
  7. public class HttpTest : AHttpHandler
  8. {
  9. [Get] // url-> /Login?name=11&age=1111
  10. public string Login(string name, int age, HttpListenerRequest req, HttpListenerResponse resp)
  11. {
  12. Log.Info(name);
  13. Log.Info($"{age}");
  14. return "ok";
  15. }
  16. [Get("t")] // url-> /t
  17. public int Test()
  18. {
  19. return 1;
  20. }
  21. [Post] // url-> /Test1
  22. public int Test1(HttpListenerRequest req)
  23. {
  24. return 1;
  25. }
  26. [Get] // url-> /Test2
  27. public int Test2(HttpListenerResponse resp)
  28. {
  29. return 1;
  30. }
  31. [Get] // url-> /GetRechargeRecord
  32. public async Task<HttpResult> GetRechargeRecord(long id)
  33. {
  34. // var db = Game.Scene.GetComponent<DBProxyComponent>();
  35. // var info = await db.Query<RechargeRecord>(id);
  36. await Task.Delay(1000); // 用于测试
  37. object info = null;
  38. if (info != null)
  39. {
  40. return Ok(data: info);
  41. }
  42. else
  43. {
  44. return Error("ID不存在!");
  45. }
  46. }
  47. }
  48. }