Skip to content

Path prefix doesn't work #126

@ilzrv

Description

@ilzrv

Preflight Checklist

  • I have searched the issue tracker for an issue that matches the one I want to file, without success.
  • I am not looking for support or already pursued the available support channels without success.

Version

v.0.9.1

PHP version

7.4

Go version

No response

Expected Behavior

When the path prefix is changed, the library continues to work.

Actual Behavior

When changing the path prefix, the library does not work.

Steps To Reproduce

  1. Add to the .proto file package apis.inter.services;
  2. Register a handler
$this->router->registerHandler(
    MyServer::PATH_PREFIX,
    new MyServer($this->service)
);
  1. After generating the MyServer class in the PATH_PREFIX constant:
final class MyServer implements RequestHandlerInterface
{
    const PATH_PREFIX = '/twirp/apis.inter.services.My/';
//...
  1. But below the code (MyServer) we have a switch:
switch ($req->getUri()->getPath()) {
    case '/twirp/apis.inter.services.My/Create': // <-- full path?
        return $this->handleCreate($ctx, $req);

    default:
        return $this->writeError($ctx, $this->noRouteError($req));
}

This switch does not use path prefix from constructor in ANY way, which we specify when registering the handler. Looks like a serious mistake. Why pass a prefix if it's always the same?

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions