News for hackers. Stuff that matters.
Re:Show HN: Java REST without annotations, DI nor reactive s... by marginalia_nu on Sunday June 11, 2023 @04:37PM (#36285396)
Hmm, a lot of my endpoints (in Spark) tend to look like

        public SomeService() {
           Spark.post("some/endpoint", this::someEndpoint, gson::toJson);
           Spark.get("another/endpoint/:id". this::anotherEndpoint, gson::toJson);
           //...
         }


        private ResponseType someEndpoint(Request request, Response response) {
           Something some = gson.fromJson(request.body(), Something.class);

           return new ResponseType(some.a, logic(some));
        }

        private ResponseType2 anotherEndpoint(Request request, Response response) {
           return new ResponseType2(otherLogic(request.param("id"));
        }
Like yeah I guess it could be have more well integrated json support, but it's not like this is heavy in boilerplate, and I do think it balances the need to occasionally access more low-level aspects of the HTTP stack well.

Not to detract from your project, of course.

There are no comments on this comment yet.