Example #1
0
        static void WriteResponseForGetTime(HttpRequest request, HttpResponse response)
        {
            var body = new ResponseFormatter(response, formatBody: true);

            body.Format(@"<html><head><title>Time</title></head><body>{0:O}</body></html>", DateTime.UtcNow);

            WriteCommonHeaders(response, HttpVersion.V1_1, 200, "OK", keepAlive: false);
            var headers = new ResponseFormatter(response, formatBody: false);

            headers.Append("Content-Length : ");
            headers.Append(response.BodyLength);
            headers.AppendHttpNewLine();
            headers.AppendHttpNewLine();
        }
Example #2
0
    public async Task <Result> ProcessAsync(UserMessage request)
    {
        if (string.IsNullOrWhiteSpace(request.Message))
        {
            return(new Result.Error(new ArgumentException("Cannot be empty or whitespace", nameof(request.Message))));
        }

        var userCommands = await _storage.GetUserCommandsAsync(request.UserId);

        var(query, shard) = MessageParser.Parse(userCommands, request);
        await _storage.SaveAsync(shard);

        return(ResponseFormatter.Format(query, await _storage.FetchAsync(query)));
    }