Class JStachioHttpMessageConverter

java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<Object>
io.jstach.opt.spring.web.JStachioHttpMessageConverter
All Implemented Interfaces:
org.springframework.http.converter.HttpMessageConverter<Object>

public class JStachioHttpMessageConverter extends org.springframework.http.converter.AbstractHttpMessageConverter<Object>
Typesafe way to use JStachio in Spring Web.

For this to work the controllers need to return JStache models and have the controller method return annotated with ResponseBody.

Example:


 @JStache
 public record HelloModel(String message){}

 @GetMapping(value = "/")
 @ResponseBody
 public HelloModel hello() {
     return new HelloModel("Spring Boot is now JStachioed!");
 }
  
Author:
agentgt
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create http converter from jstachio
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canRead(Class<?> clazz, org.springframework.http.MediaType mediaType)
     

    Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

    canWrite, getDefaultCharset, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.http.converter.HttpMessageConverter

    getSupportedMediaTypes
  • Constructor Details

    • JStachioHttpMessageConverter

      Create http converter from jstachio
      Parameters:
      jstachio - an instance usually created by spring
  • Method Details

    • canRead

      public boolean canRead(Class<?> clazz, org.springframework.http.MediaType mediaType)
      Specified by:
      canRead in interface org.springframework.http.converter.HttpMessageConverter<Object>
      Overrides:
      canRead in class org.springframework.http.converter.AbstractHttpMessageConverter<Object>