aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Net/IHttpResultFactory.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-12-07 10:52:38 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-12-07 10:52:38 -0500
commitf32212d160f5427a56b5b8e0219206930c518b64 (patch)
treeeddda40fe8c4d46cd0a0009939607681da89f03c /MediaBrowser.Controller/Net/IHttpResultFactory.cs
parent1b1bcabbb12a3ab2c9b8c5b319423eb3860c9987 (diff)
update to service stack v4
Diffstat (limited to 'MediaBrowser.Controller/Net/IHttpResultFactory.cs')
-rw-r--r--MediaBrowser.Controller/Net/IHttpResultFactory.cs98
1 files changed, 98 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Net/IHttpResultFactory.cs b/MediaBrowser.Controller/Net/IHttpResultFactory.cs
new file mode 100644
index 000000000..0614db12e
--- /dev/null
+++ b/MediaBrowser.Controller/Net/IHttpResultFactory.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading.Tasks;
+using ServiceStack.Web;
+
+namespace MediaBrowser.Controller.Net
+{
+ /// <summary>
+ /// Interface IHttpResultFactory
+ /// </summary>
+ public interface IHttpResultFactory
+ {
+ /// <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>(IRequest 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>(IRequest 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>(IRequest 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(IRequest 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="fileShare">The file share.</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(IRequest requestContext, string path, FileShare fileShare = FileShare.Read, IDictionary<string, string> responseHeaders = null, bool isHeadRequest = false);
+ }
+}