Renjith
Renjith

Reputation: 1154

Meaning of Path expression

Can you tell how does the following path expression resolve?. I am having it on top of a REST api.

@Path("{a:forgotpwd|forgot/pwd/apitoken}")

Where Path is javax.ws.rs.Path

Upvotes: 0

Views: 114

Answers (1)

tgdavies
tgdavies

Reputation: 11421

See https://docs.oracle.com/cd/E19798-01/821-1841/6nmq2cp26/index.html

a is the name of a path parameter, and forgotpwd|forgot/pwd/apitoken is the regex its value must match.

So:

@Path("{a:forgotpwd|forgot/pwd/apitoken}")
@GET
Response foo(@PathParam("a") a) {
  if (a.equals("forgotpwd") {
     ...
  } else {
     ...
  }
}

will match the URLs forgotpwd or forgot/pwd/apitoken (with whatever leading component is configured of course). Other paths will return 404.

Upvotes: 2

Related Questions