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

Support unmarshalling handler parameters #47

Merged
merged 4 commits into from
Dec 24, 2023
Merged

Conversation

thekid
Copy link
Member

@thekid thekid commented Dec 22, 2023

Example:

use com\example\ObjectId;
use web\frontend\{Handler, Get};

#[Handler('/posts')]
class Posts {

  #[Get('/{id}')]
  public function get(ObjectId $id) {
    return ['id' => $id->string()];
  }
}

This would previously raise the following error: Argument 1 ($id) must be of type com\example\ObjectId, string given. This pull request makes this library behave consistently with https://github.com/xp-forge/rest-api

@thekid thekid added the enhancement New feature or request label Dec 22, 2023
@@ -47,30 +47,30 @@ public function name() {
* Returns a map of named sources to read arguments from request. Lazily
* initialized on first use.
*
* @return [:(function(web.Request, string): var)]
* @return [:web.frontend.Parameter]
Copy link
Member Author

Choose a reason for hiding this comment

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

This Parameter class is invokeable, thus old code relying on being to use $param($request, $name) to read the parameter's value will continue to work!

@thekid thekid merged commit 0ffe61f into master Dec 24, 2023
20 checks passed
@thekid thekid deleted the feature/unmarshal branch December 24, 2023 13:52
@thekid
Copy link
Member Author

thekid commented Dec 25, 2023

@thekid
Copy link
Member Author

thekid commented Dec 25, 2023

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

Successfully merging this pull request may close these issues.

1 participant