private Response FindEndpoint(HttpListenerContext context) { var incoming = new Endpoint { Request = { Url = context.Request.Url.AbsolutePath, Method = new List <string> { context.Request.HttpMethod.ToUpper() }, Headers = CreateNameValueCollection(context.Request.Headers, caseSensitiveKeys: false), Query = CreateNameValueCollection(context.Request.QueryString), Post = utils.ReadPost(context.Request) } }; var found = _endpointDb.Find(incoming); return(found); }
/// <summary> /// Find an endpoint by it's matching Request /// </summary> /// <param name="request">The signature of the request to find by</param> public Response Find(Request request) { return(_endpointDb.Find(new Endpoint { Request = request })); }
public void Find_ShouldRetreiveEndpoint_WhenMethodInList() { var inserted = new Endpoint { Request = new Request { Url = "/phantom", Method = new List <string> { "POST" } } }; var incoming = new Endpoint { Request = new Request { Url = "/phantom", Method = new List <string> { "POST" }, Post = "A string!" } }; _endpointDb.Insert(inserted); var actual = _endpointDb.Find(incoming); Assert.NotNull(actual); }