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

http: add handler_base::verify_mandatory_params() #2084

Closed

Conversation

tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Feb 7, 2024

before this change, this member function was a free function called
by routes::handle(), but since handler_base is closer to the
_mandatory_param and in the following change, we will store
the expected param types in _mandatory_param, this makes
handler_base a better home for the verification function. so to
prepare for the change, let's move this free function into handler_base.

also, let's mark _mandatory_param private, allows us to store the
typing of the params into _mandatory_param. as this variable should
not be visible from the outer world. and the typing information should
be opaque from the caller.

Refs #2082
Signed-off-by: Kefu Chai [email protected]

@@ -66,8 +67,7 @@ public:
return *this;
}

std::vector<sstring> _mandatory_param;

friend class routes;
Copy link
Contributor

Choose a reason for hiding this comment

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

This caught my eye. I think it's better to get const getter for _mandatory_param reference, or move the verify_param() helper to be handler_base's method

Copy link
Contributor Author

@tchaikov tchaikov Feb 9, 2024

Choose a reason for hiding this comment

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

i plan to stuff move info into _mandatory_param, so we can verify the type of the params right in seastar, instead of in the higher application level. so the const getter is a no-go, as it exposes the internals to the public. so i am repurposing this PR to go with the 2nd route.

before this change, this member function was a free function called
by `routes::handle()`, but since `handler_base` is closer to the
`_mandatory_param` and in the following change, we will store
the expected param types in `_mandatory_param`, this makes
`handler_base` a better home for the verification function. so to
prepare for the change, let's move this free function into handler_base.

also, let's mark `_mandatory_param` private, allows us to store the
typing of the params into `_mandatory_param`. as this variable should
not be visible from the outer world. and the typing information should
be opaque from the caller.

Refs scylladb#2082
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov tchaikov force-pushed the more-privacy-for-handler_base branch from 185957e to 6e8f835 Compare February 9, 2024 15:39
@tchaikov tchaikov changed the title http: mark handler_base::_mandatory_param private http: add handler_base::verify_mandatory_params() Feb 9, 2024
@tchaikov
Copy link
Contributor Author

tchaikov commented Feb 9, 2024

v2:

  • "move the verify_param() helper to be handler_base's method"

@xemul xemul closed this in 09a59a2 Feb 9, 2024
@tchaikov tchaikov deleted the more-privacy-for-handler_base branch February 9, 2024 16:16
graphcareful pushed a commit to graphcareful/seastar that referenced this pull request Mar 20, 2024
before this change, this member function was a free function called
by `routes::handle()`, but since `handler_base` is closer to the
`_mandatory_param` and in the following change, we will store
the expected param types in `_mandatory_param`, this makes
`handler_base` a better home for the verification function. so to
prepare for the change, let's move this free function into handler_base.

also, let's mark `_mandatory_param` private, allows us to store the
typing of the params into `_mandatory_param`. as this variable should
not be visible from the outer world. and the typing information should
be opaque from the caller.

Refs scylladb#2082
Signed-off-by: Kefu Chai <[email protected]>

Closes scylladb#2084
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.

None yet

2 participants