HttpTest.cs 900 B

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