Exemplo n.º 1
0
        private Response GetResponse(Route route, NancyContext context)
        {
            _logger.Info($"(SUCCESS) {Context.ResolvedRoute.Description.Path}");
            context.Items.Add(RouteResolvedKey, true);

            var contentType       = context.Request.Headers.Accept.FirstOrDefault();
            var contentTypeString = contentType == null
                ? "application/json"
                : contentType.Item1;

            Response response = _engine.Parse(route.Template, Context.GetParameters());

            response
            .WithContentType($"{contentTypeString}")
            .WithStatusCode(route.Status);

            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="templateName"></param>
        /// <param name="model"></param>
        /// <param name="cultureInfo"></param>
        /// <returns></returns>
        public string Parse(string templateName, dynamic model, CultureInfo cultureInfo = null)
        {
            var templateContent = GetContent(templateName, cultureInfo);

            return(_templateEngine.Parse(templateContent, model));
        }