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

Overwrite Method name ? #45

Open
m7mdcc opened this issue Oct 28, 2022 · 1 comment
Open

Overwrite Method name ? #45

m7mdcc opened this issue Oct 28, 2022 · 1 comment

Comments

@m7mdcc
Copy link

m7mdcc commented Oct 28, 2022

Hi , Thanks for your work !

I'm using your package for simulate another rpc-endpoint , like i have another system who send json rpc request with method "ping" but since the method start with producer name its fail with

 "error": {
    "code": -32601,
    "message": "Method not found",

I have try to overwrite the method name by middleware like this


use Illuminate\Http\Request
 public function handle(Request $request, Closure $next)
    {
        $input = $request->all();
        Log::info("Request method ", [$input["method"], $request->method]); // Shows original request
        $request->merge([
            'method' =>  "message@" . $input['method']
        ]);
        $input = $request->all();
        $request->setMethod("message@" . $input['method']);
        Log::info("After Request method ", [$input["method"], $request->method]); // Shows modified request




        return $next($request);
    }

Bur i think its been ignored at all ..

Do you have any clues ?

Thanks

@tabuna
Copy link
Member

tabuna commented Oct 29, 2022

Hi @m7mdcc, You are using an HTTP Request and trying to set its value. Suitable values for it are usually:

'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH', 'PURGE', 'TRACE'

If you were to achieve this by rewriting the HTTP request, it would be duplicating JSON unpacking. First time for your modification, second time for analysis. Perhaps you should create your own controller with an example from here: https://sajya.github.io/docs/basic-application/

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

No branches or pull requests

2 participants