Ejemplo n.º 1
0
        public IActionResult Execute([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)]
                                     HttpRequest req,
                                     ILogger log)
        {
            try
            {
                var mapKey   = req.Query["key"].FirstOrDefault();
                var location = _locations.SingleOrDefault(x => x.Key == mapKey);
                if (location == null)
                {
                    return(new NotFoundResult());
                }

                var outputBytes = _cache.GetOrCreate(location.Key, entry => _generator.GetImageFor(location.ImageLocation));
                return(new FileContentResult(outputBytes, "image/jpeg"));
            }
            catch (Exception ex)
            {
                log.LogError(ex.ToString());
                throw;
            }
        }