#No boilerplate REST backed api

7 messages · Page 1 of 1 (latest)

frank flax
#

Hi! Is there a no boilerplate rest api like there are in Rust, Go and Node? I don't want to make XML files and other stuff, I just want a simple way to make a rest api in Java

random fjordBOT
#

This post has been reserved for your question.

Hey @frank flax! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

frank flax
#

bump

marble swan
#

Javalin exists

#

and if you need something more powerful, you could use Spring Boot which can do it with only a bit of boilerplate:

@SpringBootApplication
public class YourApplicationClass{
  public static void main(String[] args){
    SpringApplication.run(YourApplicationClass.class, args);
  }
}
record YourEntity(String someString, int someInt){}
@RestController
public class YourAPIController{
  @GetMapping("/test")
  public YourEntity handleSomeRequest(){
    return new YourEntity("Hello World",1337);
  }
}

This would requests to localhost:8080/test yielding the following response (or similar):

{
  "someString": "Hello World",
  "someInt": 1337;
}
frank flax