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

Generic app constructor #408

Merged
merged 3 commits into from
May 23, 2022
Merged

Generic app constructor #408

merged 3 commits into from
May 23, 2022

Conversation

dranikpg
Copy link
Member

The crow app currently has only a default constructor. This is quite unhandy for initializing middleware, as all of them have to be default-construtible and have to be initialized manually by extracting them out of the app one by one.

Instead, users should be able to provide already constructed middleware. Ideally this should work without listing all middleware, but only by specifying the required ones.

What works now:

// no default or copy constructor required, it supports move-only
struct D {
  D() = delete;
  D(const D&) = delete;
};

// Any subset can be specified
// in any order
crow::App<A, B, C, D> app(D{args...}, A{args...});

What it looked like before:

crow::App<A, B, C, D> app;
app.get_middleware<A>() = A{args...};
app.get_middleware<D>() = D{args...};

Note: this has to be merged after blueprint middleware, as it has some conflicts. Just puttin' it on the waiting list 😃

@The-EDev
Copy link
Member

I'm guessing this is ready for review? @dranikpg

@dranikpg
Copy link
Member Author

It is. I've just been waiting for the CI build to finish 👀 It did so for amd64, so it'll most likely for the other targets

@dranikpg dranikpg marked this pull request as ready for review May 23, 2022 18:16
@The-EDev
Copy link
Member

seems like the test was blocked for ARM64, might be a one off bug..

Copy link
Member

@The-EDev The-EDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems to be alright. Thanks a lot for your work and patience @dranikpg

@The-EDev
Copy link
Member

Note to self: It might be worth documenting this feature either in guides or examples.

@The-EDev The-EDev merged commit 0fb91ae into CrowCpp:master May 23, 2022
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

Successfully merging this pull request may close these issues.

2 participants