HttpTest.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. System.Console.WriteLine("");
  20. return 1;
  21. }
  22. [Post] // url-> /Test1
  23. public int Test1(HttpListenerRequest req)
  24. {
  25. return 1;
  26. }
  27. [Get] // url-> /Test2
  28. public int Test2(HttpListenerResponse resp)
  29. {
  30. return 1;
  31. }
  32. [Get] // url-> /GetRechargeRecord
  33. public async Task<HttpResult> GetRechargeRecord(long id)
  34. {
  35. // var db = Game.Scene.GetComponent<DBProxyComponent>();
  36. // var info = await db.Query<RechargeRecord>(id);
  37. await Task.Delay(1000); // 用于测试
  38. object info = null;
  39. if (info != null)
  40. {
  41. return Ok(data: info);
  42. }
  43. else
  44. {
  45. return Error("ID不存在!");
  46. }
  47. }
  48. }
  49. }