Handler.cs 977 B

1234567891011121314151617181920212223242526272829303132
  1. using Newtonsoft.Json;
  2. namespace Masuit.MyBlogs.Core.Extensions.UEditor
  3. {
  4. /// <summary>
  5. /// Handler 的摘要说明
  6. /// </summary>
  7. public abstract class Handler
  8. {
  9. protected Handler(HttpContext context)
  10. {
  11. this.Request = context.Request;
  12. this.Response = context.Response;
  13. this.Context = context;
  14. //this.Server = context.Server;
  15. }
  16. public abstract Task<string> Process();
  17. protected string WriteJson(object response)
  18. {
  19. string jsonpCallback = Request.Query["callback"];
  20. string json = JsonConvert.SerializeObject(response);
  21. return string.IsNullOrWhiteSpace(jsonpCallback) ? json : $"{jsonpCallback}({json});";
  22. }
  23. public HttpRequest Request { get; }
  24. public HttpResponse Response { get; }
  25. public HttpContext Context { get; }
  26. //public HttpServerUtility Server { get; private set; }
  27. }
  28. }