IHttpResultFactory.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Threading.Tasks;
  5. using MediaBrowser.Common.IO;
  6. using MediaBrowser.Model.IO;
  7. using MediaBrowser.Model.Services;
  8. namespace MediaBrowser.Controller.Net
  9. {
  10. /// <summary>
  11. /// Interface IHttpResultFactory
  12. /// </summary>
  13. public interface IHttpResultFactory
  14. {
  15. /// <summary>
  16. /// Gets the result.
  17. /// </summary>
  18. /// <param name="content">The content.</param>
  19. /// <param name="contentType">Type of the content.</param>
  20. /// <param name="responseHeaders">The response headers.</param>
  21. /// <returns>System.Object.</returns>
  22. object GetResult(object content, string contentType, IDictionary<string,string> responseHeaders = null);
  23. /// <summary>
  24. /// Gets the optimized result.
  25. /// </summary>
  26. /// <typeparam name="T"></typeparam>
  27. /// <param name="requestContext">The request context.</param>
  28. /// <param name="result">The result.</param>
  29. /// <param name="responseHeaders">The response headers.</param>
  30. /// <returns>System.Object.</returns>
  31. object GetOptimizedResult<T>(IRequest requestContext, T result, IDictionary<string, string> responseHeaders = null)
  32. where T : class;
  33. /// <summary>
  34. /// Gets the optimized result using cache.
  35. /// </summary>
  36. /// <typeparam name="T"></typeparam>
  37. /// <param name="requestContext">The request context.</param>
  38. /// <param name="cacheKey">The cache key.</param>
  39. /// <param name="lastDateModified">The last date modified.</param>
  40. /// <param name="cacheDuration">Duration of the cache.</param>
  41. /// <param name="factoryFn">The factory function that creates the response object.</param>
  42. /// <param name="responseHeaders">The response headers.</param>
  43. /// <returns>System.Object.</returns>
  44. object GetOptimizedResultUsingCache<T>(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, IDictionary<string, string> responseHeaders = null)
  45. where T : class;
  46. /// <summary>
  47. /// Gets the cached result.
  48. /// </summary>
  49. /// <typeparam name="T"></typeparam>
  50. /// <param name="requestContext">The request context.</param>
  51. /// <param name="cacheKey">The cache key.</param>
  52. /// <param name="lastDateModified">The last date modified.</param>
  53. /// <param name="cacheDuration">Duration of the cache.</param>
  54. /// <param name="factoryFn">The factory fn.</param>
  55. /// <param name="contentType">Type of the content.</param>
  56. /// <param name="responseHeaders">The response headers.</param>
  57. /// <returns>System.Object.</returns>
  58. object GetCachedResult<T>(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, string contentType, IDictionary<string, string> responseHeaders = null)
  59. where T : class;
  60. /// <summary>
  61. /// Gets the static result.
  62. /// </summary>
  63. /// <param name="requestContext">The request context.</param>
  64. /// <param name="cacheKey">The cache key.</param>
  65. /// <param name="lastDateModified">The last date modified.</param>
  66. /// <param name="cacheDuration">Duration of the cache.</param>
  67. /// <param name="contentType">Type of the content.</param>
  68. /// <param name="factoryFn">The factory fn.</param>
  69. /// <param name="responseHeaders">The response headers.</param>
  70. /// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param>
  71. /// <returns>System.Object.</returns>
  72. Task<object> GetStaticResult(IRequest requestContext,
  73. Guid cacheKey,
  74. DateTime? lastDateModified,
  75. TimeSpan? cacheDuration,
  76. string contentType, Func<Task<Stream>> factoryFn,
  77. IDictionary<string, string> responseHeaders = null,
  78. bool isHeadRequest = false);
  79. /// <summary>
  80. /// Gets the static result.
  81. /// </summary>
  82. /// <param name="requestContext">The request context.</param>
  83. /// <param name="options">The options.</param>
  84. /// <returns>System.Object.</returns>
  85. Task<object> GetStaticResult(IRequest requestContext, StaticResultOptions options);
  86. /// <summary>
  87. /// Gets the static file result.
  88. /// </summary>
  89. /// <param name="requestContext">The request context.</param>
  90. /// <param name="path">The path.</param>
  91. /// <param name="fileShare">The file share.</param>
  92. /// <returns>System.Object.</returns>
  93. Task<object> GetStaticFileResult(IRequest requestContext, string path, FileShareMode fileShare = FileShareMode.Read);
  94. /// <summary>
  95. /// Gets the static file result.
  96. /// </summary>
  97. /// <param name="requestContext">The request context.</param>
  98. /// <param name="options">The options.</param>
  99. /// <returns>System.Object.</returns>
  100. Task<object> GetStaticFileResult(IRequest requestContext,
  101. StaticFileResultOptions options);
  102. }
  103. }