Skip to content

Support inline constraint definitions #22

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

Open
filipw opened this issue Jan 22, 2018 · 0 comments
Open

Support inline constraint definitions #22

filipw opened this issue Jan 22, 2018 · 0 comments

Comments

@filipw
Copy link
Owner

filipw commented Jan 22, 2018

I'd like to see syntax like this:

opt.
   Get("api/other", c => c.Action<OtherController>(x => x.Action1())).
   WithConstraints(ctx => {
            // only allow route to be hit if the predefined header is present
            if (context.RouteContext.HttpContext.Request.Headers.ContainsKey("CustomHeader"))
            {
                return true;
            }

            return false;
});

So basically, avoiding having a constraint class.

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

No branches or pull requests

1 participant