Make links to feeds backward compatible

This commit is contained in:
Maksym Pavlenko
2016-12-24 14:40:32 -08:00
parent 5332c13a2a
commit 64651523c0
6 changed files with 19 additions and 7 deletions
+4 -3
View File
@@ -37,7 +37,7 @@ namespace Podsync.Controllers
[HttpPost]
[Route("create")]
[ValidateModelState]
public Task<string> Create([FromBody] CreateFeedRequest request)
public async Task<Uri> Create([FromBody] CreateFeedRequest request)
{
var linkInfo = _linkService.Parse(new Uri(request.Url));
@@ -56,11 +56,12 @@ namespace Podsync.Controllers
feed.PageSize = DefaultPageSize;
}
return _storageService.Save(feed);
var feedId = await _storageService.Save(feed);
return _linkService.Feed(feedId);
}
[HttpGet]
[Route("{feedId}")]
[Route("~/{feedId:length(4, 6)}")]
[ValidateModelState]
public async Task<IActionResult> Feed([Required] string feedId)
{
@@ -19,6 +19,8 @@ namespace Podsync.Controllers
_resolverService = resolverService;
}
[HttpGet]
[Route("~/status")]
public async Task<string> Index()
{
var storageStatus = ErrorStatus;
@@ -9,5 +9,7 @@ namespace Podsync.Services.Links
Uri Make(LinkInfo info);
Uri Download(string feedId, string videoId);
Uri Feed(string feedId);
}
}
@@ -206,5 +206,10 @@ namespace Podsync.Services.Links
{
return new Uri(_baseUrl, $"download/{feedId}/{videoId}/");
}
public Uri Feed(string feedId)
{
return new Uri(_baseUrl, feedId);
}
}
}
+2
View File
@@ -10,6 +10,8 @@ services:
- PORT=56247
environment:
- Podsync:RedisConnectionString=redis
env_file:
- ~/podsync.env
redis:
image: redis
command: redis-server --appendonly yes
+4 -4
View File
@@ -16,10 +16,10 @@ $(function () {
method: 'POST',
data: JSON.stringify(data),
contentType: 'application/json; charset=utf-8',
success: function (feedId) {
var proto = $(location).attr('protocol');
var host = $(location).attr('host');
done(proto + '//' + host + '/feed/' + feedId);
success: function (feedLink) {
// HACK: remove quotes
feedLink = JSON.parse(feedLink);
done(feedLink);
},
error: function (xhr, status, error) {
if (xhr.status === 400) {