コード例 #1
0
        private async Task <IActionResult> ServeBuildFileAsync(string buildHash, BuildFile buildFile,
                                                               CancellationToken cancel)
        {
            var buffer = await _builds.LoadBuildContentAsync(buildHash, buildFile, cancel);

            if (buffer == null)
            {
                return(NotFound());
            }
            Response.Headers.Add(HeaderNames.ETag, buildHash);
            Response.Headers.Add(HeaderNames.CacheControl, "public,max-age=31536000");
            switch (buildFile)
            {
            case BuildFile.MonoJs:
                return(File(buffer, "application/javascript"));

            case BuildFile.MonoWasm:
                return(File(buffer, "application/wasm"));

            default:
                throw new ArgumentOutOfRangeException(nameof(buildFile), buildFile, null);
            }
        }