public IActionResult Create(string id, string url) { if (IsNotAbsoluteUri(url)) { return(BadRequest("Invalid or missing URL")); } saveLink.WithIdAndUrl(id, new Uri(url)); return(CreatedAtRoute("Follow", new { id }, url)); bool IsNotAbsoluteUri(string uri) => !Uri.IsWellFormedUriString(uri, UriKind.Absolute); }
public IHttpActionResult Create(string id, [FromBody] string url) { _saveLink.WithIdAndUrl(id, new Uri(url)); return(CreatedAtRoute("Follow", new { id }, url)); }