Uniform webhook and Kirby route doesn't work

Hey guys,

I’m trying to build a formular with the help of the Uniform plugin by @mzur: https://github.com/mzur/kirby-uniform

The formular should send the data to a URL within the same kirby installation, which is done with a webhook and a custom kirby route. But here’s the problem: no matter which options I change and how I implement the route, the route doesn’t work – I always get the 404 error page as a remote response. If I try to access the routed URL directly, it works perfectly.

The relevant code snippets are:

// site/plugins/api/api.php
// API routing is done here
<?php
kirby()->routes([
    [
        'pattern' => 'api/drabo/signup',
        'method'  => 'POST',
        'action'  => function(){
            // try to trigger the error response for uniform doesn't work
            return response::error($msg);
    ]
]);
// My formular controller
// site/controllers/signup.php
<?php
return function($site, $pages, $page){
    // set required array; this works perfect
    $required = […];
    $formular = uniform($formid, [
        'required' => $required,
        'actions' => [
            [
                '_action' => 'webhook',
                'url'     => 'http://local-url/api/drabo/signup',
                'params'  => [
                    'method' => 'POST'
                ]
            ]
        ]
    ]);
};

Validating the formular, sending emails etc. does work, so there seems to be no problem with uniform itself, but with the routing (and/or the combination from both). I already tried removing the method(s), and changing the URL, but without success.

Has anyone a hint for me, and/or experience with Uniform plugin and webhooks?

Webhooks are useful if the URL is on another server. Since the API is defined in the same Kirby installation, what about calling a function directly? You can define your own custom Uniform action that can do this, even in your API plugin so that the code is kept clean.

This might be a solution. Thanks for the hint!