IHttpHandler.cs 610 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Net;
  2. namespace ETModel
  3. {
  4. public interface IHttpHandler
  5. {
  6. void Handle(HttpListenerContext context);
  7. }
  8. public abstract class AHttpHandler : IHttpHandler
  9. {
  10. public virtual void Handle(HttpListenerContext context)
  11. {
  12. }
  13. public virtual HttpResult Ok(string msg = "", object data = null)
  14. {
  15. return new HttpResult
  16. {
  17. code = HttpErrorCode.Success,
  18. msg = msg,
  19. status = true,
  20. data = data
  21. };
  22. }
  23. public virtual HttpResult Error(string msg = "")
  24. {
  25. return new HttpResult
  26. {
  27. code = HttpErrorCode.Exception,
  28. msg = msg,
  29. status = false
  30. };
  31. }
  32. }
  33. }