public MainModule()
        {
            Get("/", _ =>
            {
                HttpClient client = new HttpClient();

                var st = client.GetStreamAsync("http://localhost:9999/msg").Result;

                return((string)DefaultMessagePackSerializer.Deserialize(st));
            });

            Get("/msg", _ =>
            {
                return(Response.AsMessagePack("123"));
            });
        }
示例#2
0
        private static void CheckResponse(BrowserResponse response, string name, int age)
        {
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(ConstValue.MessagePackContentType, response.Context.Response.ContentType);
            Assert.IsType <MessagePackResponse>(response.Context.Response);

            using (var memStream = new MemoryStream())
            {
                response.Context.Response.Contents(memStream);

                var returnedUser = DefaultMessagePackSerializer.Deserialize <User>(memStream);

                Assert.NotNull(returnedUser);
                Assert.Equal(name, returnedUser.Name);
                Assert.Equal(age, returnedUser.Age);
            }
        }