diff options
author | crupest <crupest@outlook.com> | 2020-02-03 18:18:45 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-02-03 18:18:45 +0800 |
commit | 86c4e7834bf25b900af03edc53aea3f37f645334 (patch) | |
tree | 28ef20f9dfe742008bb934f09b99d1d4719cabaa /Timeline/Controllers | |
parent | 4b2569368073bbd556bbe71bd51807de91f814cb (diff) | |
download | timeline-86c4e7834bf25b900af03edc53aea3f37f645334.tar.gz timeline-86c4e7834bf25b900af03edc53aea3f37f645334.tar.bz2 timeline-86c4e7834bf25b900af03edc53aea3f37f645334.zip |
Finish normal timeline development.
Diffstat (limited to 'Timeline/Controllers')
-rw-r--r-- | Timeline/Controllers/TimelineController.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index d46189b8..a514ccd9 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Timeline.Filters;
using Timeline.Models.Http;
using Timeline.Models.Validation;
using Timeline.Services;
@@ -11,6 +12,7 @@ using Timeline.Services; namespace Timeline.Controllers
{
[ApiController]
+ [CatchTimelineNotExistException]
public class TimelineController : Controller
{
private readonly ILogger<TimelineController> _logger;
@@ -26,7 +28,8 @@ namespace Timeline.Controllers [HttpGet("timelines/{name}")]
public async Task<ActionResult<TimelineInfo>> TimelineGet([FromRoute][TimelineName] string name)
{
- return (await _service.GetTimeline(name)).FillLinksForNormalTimeline(Url);
+ var result = (await _service.GetTimeline(name)).FillLinksForNormalTimeline(Url);
+ return Ok(result);
}
[HttpGet("timelines/{name}/posts")]
@@ -128,13 +131,13 @@ namespace Timeline.Controllers [HttpPost("timelines")]
[Authorize]
- public async Task<ActionResult<TimelineInfo>> TimelineCreate([FromRoute] TimelineCreateRequest body)
+ public async Task<ActionResult<TimelineInfo>> TimelineCreate([FromBody] TimelineCreateRequest body)
{
var userId = this.GetUserId();
try
{
- var timelineInfo = await _service.CreateTimeline(body.Name, userId);
+ var timelineInfo = (await _service.CreateTimeline(body.Name, userId)).FillLinksForNormalTimeline(Url);
return Ok(timelineInfo);
}
catch (ConflictException)
|