server icon indicating copy to clipboard operation
server copied to clipboard

Overwrite Method name ?

Open m7mdcc opened this issue 3 years ago • 1 comments

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

m7mdcc avatar Oct 28 '22 03:10 m7mdcc

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/

tabuna avatar Oct 29 '22 22:10 tabuna