Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route matching ignores HTTP method #3

Open
benfoster opened this issue Jun 14, 2014 · 0 comments
Open

Route matching ignores HTTP method #3

benfoster opened this issue Jun 14, 2014 · 0 comments

Comments

@benfoster
Copy link

As discussed, route matching appears to be ignoring the HTTP method. In the test below the GET route is always hit, even when making a POST.

namespace Superscribe.Tests.Owin
{
    class RoutingTests
    {
        static TestServer owinTestServer;
        static HttpClient client;

        static HttpResponseMessage response;

        Establish context = () =>
        {
            owinTestServer = TestServer.Create(app =>
            {
                var define = OwinRouteEngineFactory.Create();

                define.Get("products", ctx => "Hello");
                define.Post("products", ctx =>
                {
                    ctx.StatusCode = (int)HttpStatusCode.Created;
                    return "Created";
                });

                app.UseSuperscribeRouter(define)
                    .UseSuperscribeHandler(define);
            });

            client = owinTestServer.HttpClient;
            client.DefaultRequestHeaders.Add("accept", "text/html");
        };

        class When_requesting_a_valid_route_with_matching_verb
        {
            Because of = () => response = client.GetAsync("http://localhost/products").Await();

            It Should_return_200 = () =>
            {
                response.StatusCode.ShouldEqual(HttpStatusCode.OK);
            };
        }

        class When_requesting_a_valid_route_different_verb
        {
            Because of = () => response = client.PostAsync("http://localhost/products", new StringContent("test")).Await();

            It Should_not_match_the_route = () =>
            {
                response.StatusCode.ShouldEqual(HttpStatusCode.Created);
            };
        }
    }
}

Also I noticed that a template of products would also match products/add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant