Example #1
0
        public JObject Index()
        {
            var parsed = _linkParser.ParsePathByEndpointName("default", HttpContext.Request.Path);

            if (parsed == null)
            {
                throw new Exception("Parsing failed.");
            }

            return(ToJObject(parsed));
        }
Example #2
0
    public IActionResult AddRelatedProduct(
        string id, string pathToRelatedProduct, [FromServices] LinkParser linkParser)
    {
        var routeValues = linkParser.ParsePathByEndpointName(
            nameof(GetProduct), pathToRelatedProduct);
        var relatedProductId = routeValues?["id"];

        // ...
        // </snippet_AddRelatedProduct>

        return(NoContent());
    }