How to include `:` in an http path in an Armeria Server?

81 views Asked by At

I want to create an endpoint similar to this:

POST /someresource:validate

Based on Google API Guideliness for custom methods.

But when I add it I get this error:

Exception in thread "main" java.lang.IllegalArgumentException: pathPattern: /someresource:validate (invalid pattern)

I think this happens because of Path Pattern syntax. Is there a way to configure so we can disable some syntax options so we can use : inside url names? Or is there another way.

1

There are 1 answers

1
jrhee17 On BEST ANSWER

Unfortunately, I think the best workaround is to do something like the following for now:

sb.serviceUnder("/resource", (ctx, req) -> {
    final String nameAndVerb = req.path().substring(req.path().lastIndexOf('/') + 1);
    System.out.println(nameAndVerb);
    return HttpResponse.of(200);
});

I would expect something like the following to work, but it seems like there is a bug internally.

sb.service("exact:/resource/name:customVerb", (ctx, req) -> HttpResponse.of(200));

I've filed an issue for this. https://github.com/line/armeria/issues/4577