コード例 #1
0
        public IHttpResponse Handle(IHttpRequest request)
        {
            string resourceExtension = ResourceUtilities.GetResourceExtension(request.Path);
            string resourceFullName  = ResourceUtilities.GetResourceFullName(request.Path, resourceExtension);
            string resourceFile      = $"{MvcContext.Get.ResourcesFolder}/{resourceExtension.Substring(1)}/{resourceFullName}";

            if (!File.Exists(resourceFile))
            {
                return(new HttpResponse(HttpResponseStatusCode.NotFound));
            }
            byte[] content = File.ReadAllBytes(resourceFile);

            return(new InlineResourceResult(content, HttpResponseStatusCode.Ok));
        }