Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

fizzed/ninja-java8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ninja Framework + Java8 by Fizzed

Overview

Java8 extensions for Ninja Framework. Very much a beta and a work-in-progress.

Simply change root package ninja to ninja8 for new Router and ApplicationRoutes interfaces. New with() method becomes available that accepts a functional interface.

package conf;

import controllers.Application;
import ninja8.Router;
import ninja8.application.ApplicationRoutes;

public class Routes implements ApplicationRoutes {

    @Override
    public void init(Router router) {

        router.GET().route("/").with(Application::index);

    }
    
}

Reverse routing also works

public class Application {
    
    final private ninja8.Router router;
    
    @Inject
    public Application(ninja8.Router router) {
        this.router = router;
    }
    
    public Result index(Context context) {
        return Results
            .ok()
            .template("views/index.ftl.html")
            .render((Object)null);
    }
    
    public Result reverse() {
        String url = router.getReverseRoute(MethodReference.of(this::index));
        log.info("url for index: {}", url);
        
        // rest of method
    }
    
}

Demo

This module is not yet released on Maven central. You'll need to clone this repo and try the demo app:

mvn -Pninja-run

License

Copyright (C) 2015 Fizzed, Inc.

This work is licensed under the Apache License, Version 2.0.

About

Java 8 extensions for NinjaFramework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages