sonarr-repo-only/NzbDrone.Api/Directories/DirectoryModule.cs

37 lines
1013 B
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Nancy;
2013-02-23 20:35:26 +00:00
using NzbDrone.Api.Extensions;
using NzbDrone.Common;
namespace NzbDrone.Api.Directories
{
public class DirectoryModule : NzbDroneApiModule
{
private readonly IDirectoryLookupService _directoryLookupService;
public DirectoryModule(IDirectoryLookupService directoryLookupService)
: base("/directories")
{
_directoryLookupService = directoryLookupService;
2013-02-15 23:38:53 +00:00
Get["/"] = x => GetDirectories();
}
private Response GetDirectories()
{
2013-02-15 23:38:53 +00:00
if (!Request.Query.query.HasValue)
return new List<string>().AsResponse();
2013-02-15 23:38:53 +00:00
string query = Request.Query.query.Value;
var dirs = _directoryLookupService.LookupSubDirectories(query);
if (dirs == null)
throw new Exception("A valid path was not provided");
return dirs.AsResponse();
}
}
}