aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Net/IHttpResultFactory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common/Net/IHttpResultFactory.cs')
-rw-r--r--MediaBrowser.Common/Net/IHttpResultFactory.cs92
1 files changed, 90 insertions, 2 deletions
diff --git a/MediaBrowser.Common/Net/IHttpResultFactory.cs b/MediaBrowser.Common/Net/IHttpResultFactory.cs
index 565a2dce9..55c0e5b9b 100644
--- a/MediaBrowser.Common/Net/IHttpResultFactory.cs
+++ b/MediaBrowser.Common/Net/IHttpResultFactory.cs
@@ -1,9 +1,97 @@
-using System.IO;
+using ServiceStack.ServiceHost;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading.Tasks;
namespace MediaBrowser.Common.Net
{
+ /// <summary>
+ /// Interface IHttpResultFactory
+ /// </summary>
public interface IHttpResultFactory
{
- object GetResult(Stream stream, string contentType);
+ /// <summary>
+ /// Throws the error.
+ /// </summary>
+ /// <param name="statusCode">The status code.</param>
+ /// <param name="errorMessage">The error message.</param>
+ /// <param name="responseHeaders">The response headers.</param>
+ void ThrowError(int statusCode, string errorMessage, IDictionary<string, string> responseHeaders = null);
+
+ /// <summary>
+ /// Gets the result.
+ /// </summary>
+ /// <param name="content">The content.</param>
+ /// <param name="contentType">Type of the content.</param>
+ /// <param name="responseHeaders">The response headers.</param>
+ /// <returns>System.Object.</returns>
+ object GetResult(object content, string contentType, IDictionary<string,string> responseHeaders = null);
+
+ /// <summary>
+ /// Gets the optimized result.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="requestContext">The request context.</param>
+ /// <param name="result">The result.</param>
+ /// <param name="responseHeaders">The response headers.</param>
+ /// <returns>System.Object.</returns>
+ object GetOptimizedResult<T>(IRequestContext requestContext, T result, IDictionary<string, string> responseHeaders = null)
+ where T : class;
+
+ /// <summary>
+ /// Gets the optimized result using cache.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="requestContext">The request context.</param>
+ /// <param name="cacheKey">The cache key.</param>
+ /// <param name="lastDateModified">The last date modified.</param>
+ /// <param name="cacheDuration">Duration of the cache.</param>
+ /// <param name="factoryFn">The factory function that creates the response object.</param>
+ /// <param name="responseHeaders">The response headers.</param>
+ /// <returns>System.Object.</returns>
+ object GetOptimizedResultUsingCache<T>(IRequestContext requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, IDictionary<string, string> responseHeaders = null)
+ where T : class;
+
+ /// <summary>
+ /// Gets the cached result.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="requestContext">The request context.</param>
+ /// <param name="cacheKey">The cache key.</param>
+ /// <param name="lastDateModified">The last date modified.</param>
+ /// <param name="cacheDuration">Duration of the cache.</param>
+ /// <param name="factoryFn">The factory fn.</param>
+ /// <param name="contentType">Type of the content.</param>
+ /// <param name="responseHeaders">The response headers.</param>
+ /// <returns>System.Object.</returns>
+ object GetCachedResult<T>(IRequestContext requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, string contentType, IDictionary<string, string> responseHeaders = null)
+ where T : class;
+
+ /// <summary>
+ /// Gets the static result.
+ /// </summary>
+ /// <param name="requestContext">The request context.</param>
+ /// <param name="cacheKey">The cache key.</param>
+ /// <param name="lastDateModified">The last date modified.</param>
+ /// <param name="cacheDuration">Duration of the cache.</param>
+ /// <param name="contentType">Type of the content.</param>
+ /// <param name="factoryFn">The factory fn.</param>
+ /// <param name="responseHeaders">The response headers.</param>
+ /// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param>
+ /// <returns>System.Object.</returns>
+ object GetStaticResult(IRequestContext requestContext, Guid cacheKey, DateTime? lastDateModified,
+ TimeSpan? cacheDuration, string contentType, Func<Task<Stream>> factoryFn,
+ IDictionary<string, string> responseHeaders = null, bool isHeadRequest = false);
+
+ /// <summary>
+ /// Gets the static file result.
+ /// </summary>
+ /// <param name="requestContext">The request context.</param>
+ /// <param name="path">The path.</param>
+ /// <param name="responseHeaders">The response headers.</param>
+ /// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param>
+ /// <returns>System.Object.</returns>
+ object GetStaticFileResult(IRequestContext requestContext, string path, IDictionary<string, string> responseHeaders = null, bool isHeadRequest = false);
}
}