Adding a route with a POST method

I am working on building out a module that includes a GET and a POST method on an endpoint.

The GET endpoint is working great and just added with:

this.routes.newRoute("/my/endpoint")
                .handler(this::getData)
                .type(TYPE_JSON)
                .mount();

However the same way of describing the POST endpoint doesn't seem to be working?

If I just execute a curl <my-path>/my/endpoint then it works fine

However a curl -X POST -d @my-file.json <my-path>/my/endpoint I get a 404 that the page isn't there.

Is there something different I need to add to the route definition for it to see the POST request?

See RouteMounter::method. You can specify the method, it defaults to GET when not specified.

3 Likes

I have a tutorial here of how to add routes.