jellyfin/MediaBrowser.Controller/Net/IHttpResultFactory.cs

120 lines
5.6 KiB
C#
Raw Normal View History

2014-08-30 14:26:29 +00:00
using ServiceStack.Web;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
2013-03-08 17:25:25 +00:00
2013-12-07 15:52:38 +00:00
namespace MediaBrowser.Controller.Net
2013-03-08 17:25:25 +00:00
{
/// <summary>
/// Interface IHttpResultFactory
/// </summary>
2013-03-08 17:25:25 +00:00
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);
2016-07-15 17:13:55 +00:00
object GetAsyncStreamWriter(Func<Stream,Task> streamWriter, 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>
2013-12-07 15:52:38 +00:00
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>
2016-06-19 06:18:29 +00:00
Task<object> GetStaticResult(IRequest requestContext,
2014-07-17 22:21:35 +00:00
Guid cacheKey,
DateTime? lastDateModified,
TimeSpan? cacheDuration,
string contentType, Func<Task<Stream>> factoryFn,
IDictionary<string, string> responseHeaders = null,
bool isHeadRequest = false);
/// <summary>
2014-08-30 14:26:29 +00:00
/// Gets the static result.
/// </summary>
/// <param name="requestContext">The request context.</param>
2014-08-30 14:26:29 +00:00
/// <param name="options">The options.</param>
/// <returns>System.Object.</returns>
2016-06-19 06:18:29 +00:00
Task<object> GetStaticResult(IRequest requestContext, StaticResultOptions options);
/// <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>
/// <returns>System.Object.</returns>
2016-06-19 06:18:29 +00:00
Task<object> GetStaticFileResult(IRequest requestContext, string path, FileShare fileShare = FileShare.Read);
2014-08-30 14:26:29 +00:00
/// <summary>
2014-08-30 14:26:29 +00:00
/// Gets the static file result.
/// </summary>
2014-08-30 14:26:29 +00:00
/// <param name="requestContext">The request context.</param>
/// <param name="options">The options.</param>
/// <returns>System.Object.</returns>
2016-06-19 06:18:29 +00:00
Task<object> GetStaticFileResult(IRequest requestContext,
2014-08-30 14:26:29 +00:00
StaticFileResultOptions options);
2013-03-08 17:25:25 +00:00
}
}