Example #1
0
        public async Task FromMemory()
        {
            var content = @"{""Content"":""this will be in the body""}";

            var sut = ResponseFactory.From(content, HttpStatusCode.OK);

            sut.StatusCode.Should().Be(HttpStatusCode.OK);

            var body = await sut.GetResponseString();

            body.Should().Be(content);
        }
        public static IMiddlewareSetup AddControllerFunction(this IMiddlewareSetup middlewareSetup, Func <Request, bool> controllerFunctionCanHandleRequest, Func <Request, object> controllerFunc)
        {
            var controllerFunctionMiddleware = new ControllerFunctionMiddleware(controllerFunctionCanHandleRequest,
                                                                                req =>
            {
                var response = controllerFunc(req);

                return(ResponseFactory.From(response));
            });

            middlewareSetup.AddMiddleWare(controllerFunctionMiddleware);

            return(middlewareSetup);
        }