Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Using custom HTTP methods with Endpoints #186

@carise

Description

@carise

I'm reading about using custom methods for APIs and would like to implement it in an API I'm working on. The endpoint in question is something like myapi/v1/myresource/{resourceId}:myCustomMethod

But this seems to be invalid:

[INFO] GCLOUD: java.lang.IllegalArgumentException: 'myapi/v1/myresource/{resourceId}:myCustomMethod' contains invalid parameter syntax: {resourceId}:myCustomMethod
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:196)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:203)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:193)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:203)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:203)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:203)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:177)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathDispatcher$Builder.add(PathDispatcher.java:69)
[INFO] GCLOUD: 	at com.google.api.server.spi.EndpointsServlet.createDispatcher(EndpointsServlet.java:117)
[INFO] GCLOUD: 	at com.google.api.server.spi.EndpointsServlet.init(EndpointsServlet.java:58)
[INFO] GCLOUD: 	at com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:121)
[INFO] GCLOUD: 	at com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:82)
[INFO] GCLOUD: 	at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:103)
[INFO] GCLOUD: 	at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:220)
... etc

If I change the URI to myapi/v1/myresource/{resourceId}/something:myCustomMethod, the exception changes to:

[INFO] GCLOUD: java.lang.IllegalArgumentException: 'myapi/v1/myresource/{resourceId}/something:myCustomMethod' contains invalid path segment: results:propagationSummaries
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:201)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:193)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:203)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:193)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:203)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:203)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:203)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathTrie$Builder.add(PathTrie.java:177)
[INFO] GCLOUD: 	at com.google.api.server.spi.dispatcher.PathDispatcher$Builder.add(PathDispatcher.java:69)
[INFO] GCLOUD: 	at com.google.api.server.spi.EndpointsServlet.createDispatcher(EndpointsServlet.java:117)
[INFO] GCLOUD: 	at com.google.api.server.spi.EndpointsServlet.init(EndpointsServlet.java:58)

What's the right way to use custom methods? Should I instead create the endpoint to be something like: myapi/v1/myresource/{resourceId}/myCustomMethod (with the / instead of :)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions