Exemplo n.º 1
0
        public bool Matches(RequestContext ctx)
        {
            if (!String.IsNullOrEmpty(method) && ctx.Request.HttpMethod != method) return false;

            var serverPath = ctx.Request.Url.GetServerBaseUri();
            return new Uri(serverPath + uri).Equals(ctx.Request.Url);
        }
Exemplo n.º 2
0
        public Response(RequestContext context, int statusCode = 200, IEnumerable<KeyValuePair<string, string>> headers = null)
        {
            StatusCode = statusCode;
            Headers = new Dictionary<string, string> { { "Content-Type", "text/html" } };
            if (headers != null)
                foreach (var pair in headers)
                    Headers.Add(pair);

            listenerResponse = context.ListenerResponse;
        }
Exemplo n.º 3
0
        public bool Matches(RequestContext ctx)
        {
            if (!String.IsNullOrEmpty(method) && ctx.Request.HttpMethod != method) return false;

            var uriTemplate = new UriTemplate(uri);
            var serverPath = ctx.Request.Url.GetServerBaseUri();
            var uriTemplateMatch = uriTemplate.Match(new Uri(serverPath), ctx.Request.Url);
            if (uriTemplateMatch == null) return false;

            ctx.Request.LoadArguments(uriTemplateMatch.BoundVariables);
            return true;
        }
Exemplo n.º 4
0
 public Response(RequestContext context, int statusCode = 200)
 {
     StatusCode = statusCode;
     Headers = new Dictionary<string, string>{{"Content-Type", "text/html"}};
     this.listenerResponse = context.ListenerResponse;
 }
Exemplo n.º 5
0
 private static void OnUriAndMethodHandler(RequestContext ctx, IUrlMatcher matcher, IObserver<RequestContext> obs)
 {
     if (!matcher.Matches(ctx)) return;
     
     obs.OnNext(ctx);            
 }
Exemplo n.º 6
0
 public EmptyResponse(RequestContext context, int statusCode = 204)
     : base(context)
 {
     StatusCode = statusCode;
 }
Exemplo n.º 7
0
 public StringResponse(RequestContext context, string message, int statusCode = 200)
     : base(context, Encoding.UTF8.GetBytes(message), statusCode)
 {
 }
Exemplo n.º 8
0
 public BinaryResponse(RequestContext context, byte[] binary, int statusCode = 200, IDictionary<string, string> headers = null)
     : base(context, statusCode, headers)
 {
     this.binary = binary;
 }
Exemplo n.º 9
0
 public StaticFileResponse(RequestContext context, string file, int chunkSize = 1024, IEnumerable<KeyValuePair<string, string>> headers = null) : base(context, headers: headers)
 {
     this.file = file;
     this.chunkSize = chunkSize;
 }
Exemplo n.º 10
0
        private static void OnUriAndMethodHandler(
                RequestContext ctx, 
                string method, 
                UriTemplate uriTemplate, 
                IObserver<RequestContext> obs)
        {
            if (!string.IsNullOrEmpty(method) && ctx.Request.HttpMethod != method) return;

            var serverPath = ctx.Request.Url.GetServerBaseUri();
            var uriTemplateMatch = uriTemplate.Match(new Uri(serverPath), ctx.Request.Url);
            if (uriTemplateMatch == null) return;

            ctx.Request.LoadArguments(uriTemplateMatch.BoundVariables);
            obs.OnNext(ctx);
        }
Exemplo n.º 11
0
 public StringResponse(RequestContext context, string message, int statusCode = 200, IDictionary<string, string> headers = null)
     : base(context, Encoding.UTF8.GetBytes(message), statusCode, headers)
 {
 }
Exemplo n.º 12
0
 public BinaryResponse(RequestContext context, byte[] binary, int statusCode = 200)
     : base(context, statusCode)
 {
     this.binary = binary;
 }
Exemplo n.º 13
0
 public StaticFileResponse(RequestContext context, string file, int chunkSize = 1024)
     : base(context)
 {
     this.file = file;
     this.chunkSize = chunkSize;
 }
Exemplo n.º 14
0
 public EmptyResponse(RequestContext context, int statusCode = 204, IEnumerable<KeyValuePair<string, string>> headers = null) : base(context, headers: headers)
 {
     StatusCode = statusCode;
 }