joffrey-bion / livedoc

A not-so-annotation-based documentation generator for REST and websocket services
MIT License
5 stars 2 forks source link

Add GENERATED PageContentType #96

Closed ST-DDT closed 6 years ago

ST-DDT commented 6 years ago

It would be nice if there was some kind of GENERATED page content type for PageContentType.

In that case the content would refer to a class/bean that implements a certain interface which would generate the content for that page.

public interface PageGenerator {
     String generate();
}

Example

public class LimitsPageGenerator implements PageGenerator {

    @Value("${api.request.limit:-1}")
    private int requestLimit;

    public String generate() {
        if (requestLimit >= 0) {
            return "";
        }
        StringBuilder sb = new StringBuilder("<h2>Restrictions</h2>\n");
        sb.append("You may only send an API request ").append(requestLimit).append(" times per minute.");
        return sb.toString();
    }

}