HttpTest.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using ETModel;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Net;
  6. using System.Text;
  7. namespace ETHotfix
  8. {
  9. public class AccountInfo
  10. {
  11. public string name;
  12. public string pwd;
  13. }
  14. [HttpHandler(AppType.Gate, "/")]
  15. public class HttpTest : AHttpHandler
  16. {
  17. [Get] // url-> /Login?name=11&age=1111
  18. public string Login(string name, int age, HttpListenerRequest req, HttpListenerResponse resp)
  19. {
  20. Log.Info(name);
  21. Log.Info($"{age}");
  22. return "ok";
  23. }
  24. [Get("t")] // url-> /t
  25. public int Test()
  26. {
  27. return 1;
  28. }
  29. [Post] // url-> /Test1
  30. public int Test1(HttpListenerRequest req)
  31. {
  32. return 1;
  33. }
  34. [Get] // url-> /Test2
  35. public int Test2(HttpListenerResponse resp)
  36. {
  37. return 1;
  38. }
  39. [Post]
  40. public object Test3(HttpListenerResponse resp, HttpListenerRequest req, string postBody, AccountInfo accountInfo)
  41. {
  42. Log.Info(postBody);
  43. Log.Info(JsonHelper.ToJson(accountInfo));
  44. return new { name = "1111" };
  45. }
  46. }
  47. }