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

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