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

airframe-http: Routing issue #417

Closed
takezoe opened this issue Mar 4, 2019 · 2 comments
Closed

airframe-http: Routing issue #417

takezoe opened this issue Mar 4, 2019 · 2 comments

Comments

@takezoe
Copy link
Member

takezoe commented Mar 4, 2019

I defined two endpoints as:

@Endpoint(path = "/v1")
trait ResourceManagerService {
  @Endpoint(path = "/:cluster/workers/task", method = HttpMethod.GET)
  def workersTask(cluster: String) = {
    ...
  }

  @Endpoint(path = "/:cluster/workers/status", method = HttpMethod.GET)
  def workersStatus(cluster: String) = {
    ...
  }
}

Then run the following command for testing:

$ curl http://localhost/v1/hoge/workers/task

But workersStatus() was called against my expectation.

@takezoe
Copy link
Member Author

takezoe commented Mar 4, 2019

I'm investigating the cause of this behavior.

@takezoe
Copy link
Member Author

takezoe commented Mar 5, 2019

The current implementation of Router seems to allow to define the parameter (:name) only at the last component of the path.

def findRoute[A](request: HttpRequest[A]): Option[Route] = {
routes
.find { r =>
r.method == request.method &&
r.pathComponents.length == request.pathComponents.length &&
request.path.startsWith(r.pathPrefix)
}
}

lazy val pathPrefix: String = {
"/" +
pathComponents
.takeWhile(!_.startsWith(":"))
.mkString("/")
}

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

No branches or pull requests

1 participant