Exemplo n.º 1
0
        public static bool TryParse(IQueryCollection query, [NotNullWhen(true)] out DiscardParameters?parameters)
        {
            if (MiddlewareCommon.TryGetParameter(query, "doc", out var documentText) &&
                Guid.TryParseExact(documentText, GlobalConstants.GuidFormat, out var documentId))
            {
                parameters = new DiscardParameters
                {
                    DocumentId = documentId,
                };
                return(true);
            }

            parameters = default;
            return(false);
        }
Exemplo n.º 2
0
        internal override async Task <bool> ProcessRequest(HttpContext http)
        {
            if (http.Request.Method != "POST" || http.Request.Path != "/_discard" ||
                !DiscardParameters.TryParse(http, out var parameters) ||
                !MiddlewareCommon.TryFindConnection(_app, http, out var connection))
            {
                return(false);
            }
            await Task.Delay(DiscardDelay);

            await connection.Discard(parameters.DocumentId);

            await _app.ClearEmptyConnection(connection);

            return(true);
        }