예제 #1
0
        public async Task InvokeAsync(HttpContext context)
        {
            string versionParam = GetQueryParameter(context, "v");


            if (!Version.TryParse(versionParam, out Version version) || version < MinimumClientVersion)
            {
                context.Response.StatusCode  = StatusCodes.Status200OK;
                context.Response.ContentType = "text/xml";

                await context.Response.WriteAsync(
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                    $"<subsonic-response xmlns=\"http://subsonic.org/restapi\" status=\"failed\" version=\"{MinimumClientVersion.ToString(3)}\">\n" +
                    "   <error code=\"20\" message=\"Incompatible Subsonic REST protocol version. Client must upgrade.\"/>\n" +
                    "</subsonic-response>");

                return;
            }

            // Call the next delegate/middleware in the pipeline
            await _next(context);
        }