Skip to content

GuusLieben/Javalin-Annotation-Processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Javalin-Annotation-Processor

Processor to provide basic endpoint annotations to Javalin. Non-void methods annotated with @Endpoint will be converted into non-blocking endpoints. Additionally, classes annotated with @Endpoint will prepend the endpoints of all annotated methods with the provided path.

Methods returning types other than String, byte[], InputStream, or CompletableFuture will be serialized to a JSON string using Gson.

Note that void methods will require a Context parameter, this is enforced by the processor. Non-void methods can choose whether or not the Context should be provided.

The processor supports the following HTTP methods : Get, Post, Put, Patch, Delete, Head, Options. Additionally it also supports Javalin specific methods : Before, After.

Example

@Endpoint("/root")
public class ClassExample {
  
  @Endpoint("/")
  public String root() {
    return "Sample result";
   }
   
   @Endpoint("/:id")
   public String rootId(Context ctx) {
    return "Sample result with param : " + ctx.pathParam("id");
   }
   
   @Endpoint("/:id/sub")
   public void rootIdSub(Context ctx) {
    ctx.result("Parameter was : " + ctx.pathParam("id"));
   }
   
   @Endpoint("/:id", MethodType.PATCH)
   public static void updateRootId(Context ctx) {
    String body = ctx.body();
    // ... Do something
    ctx.result("Patched object with ID " + ctx.pathParam("id"));
   }
}

About

Processor to provide basic endpoint annotations to Javalin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages