Pippo

Posted by Bruce Tsai
07/27/2016

Pippo 是一個 Java 的微型 web library,具有最小化的類別庫需求及快速的學習曲線,能夠很快的讓開發人員上手。Pippo 的目標是在中小型應用中或是微型 web 應用服務中,能夠快速建置並且簡化開發的流程。

使用範例

public class BasicApplication extends Application {

    @Override
    protected void onInit() {
        // send 'Hello World' as response
        GET("/", (routeContext) -> routeContext.send("Hello World"));

        // send a file as response
        GET("/file", (routeContext) -> routeContext.send(new File("pom.xml"));

        // send a json as response
        GET("/json", (routeContext) -> {
            Contact contact = createContact();
            routeContext.json().send(contact);
        });

        // send xml as response
        GET("/xml", (routeContext) -> {
            Contact contact = createContact();
            routeContext.xml().send(contact);
        });

        // send an object and negotiate the Response content-type, default to XML
        GET("/negotiate", (routeContext) -> {
            Contact contact = createContact();
            routeContext.xml().negotiateContentType().send(contact);
        });

        // send a template as response
        GET("/template", (routeContext) -> {
            routeContext.setLocal("greeting", "Hello");
            routeContext.render("hello");        
        });
    }

}

results matching ""

    No results matching ""