Example #1
0
        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);
        }
Example #2
0
        public IHttpActionResult Create(string id, [FromBody] string url)
        {
            _saveLink.WithIdAndUrl(id, new Uri(url));

            return(CreatedAtRoute("Follow", new { id }, url));
        }