Пример #1
0
 public Server(int port)
 {
     _uriPrefix         = String.Format("http://localhost:{0}/", port);
     _baseUri           = string.Format("http://localhost:{0}/", port);
     BodyParser         = BodyParsers.DefaultBodyParser();
     BodyWriter         = BodyWriters.DefaultBodyWriter();
     ParamsParser       = new UrlParamsParser();
     _anyRequestHandler = new HttpHandler(this);
     Start();
 }
Пример #2
0
 public Server(int port)
 {
     Port               = port;
     _uriPrefix         = $"http://localhost:{port}/";
     BaseUri            = $"http://localhost:{port}/";
     BodyParser         = BodyParsers.DefaultBodyParser();
     BodyWriter         = BodyWriters.DefaultBodyWriter();
     ParamsParser       = new UrlParamsParser();
     _anyRequestHandler = new HttpHandler(this);
     Start();
 }
Пример #3
0
        public static IBodyWriter DefaultBodyWriter()
        {
            var writer = new BodyWriters();

            writer.RegisterBodyWriter <Stream>((stream, outputStream) => stream.CopyTo(outputStream));
            writer.RegisterBodyWriter <string>((str, outputStream) =>
            {
                using (var streamWriter = new StreamWriter(outputStream))
                {
                    streamWriter.Write(str);
                }
            });
            return(writer);
        }