The Ninja Web framework


#1

Hello there :-)

The Ninja framework is a fairly lightweight stack modelled loosely on the Play! framework. It’s dead easy to learn, open-source, scaleable and supports just about every other feature you’d expect to ensure full buzzword compliance.

http://www.ninjaframework.org

I had a go at converting the framework examples from Java. Turned out to be pretty straightforward:

https://github.com/MuppetGate/NinjaTest.git

Though again, the need to support nullable types in the framework made a few bits of the code a little cumbersome.

Anyway, if you’re on the lookout for a web framework that’s pretty much production-ready and is a good fit for Kotlin, then the Ninja Web framework is worth a look. With any luck, the folk at Jetbrains could work with the Ninja folk to make the framework a little more Kotlin-friendly.

Message was edited by: Rayz

Fixed duff links.


#2

P.S.

I am not affliated with either company.

:slight_smile:

Just thought I’d mention that.


#3

I don't see any Kotlin code anywhere, do you have a direct link?

Also, your links have weird linkedin redirects in them.


#4

Doh!

:8}

Thanks for that. I’ve fixed the links now.


#5

Thanks, but I'm still not seeing any Kotlin anywhere (NinjaTest only has src/main/java).


#6

Yes, I didn't change the name of folder. The Kotlin files are inside there.


#7

I've been experimenting with Kotlin/Ninja as well.  Injecting services into controllers was a bit cumbersome at first when I tried field level injection.  Initially, I believe I was doing something like this (which is similar to your InjectionExampleController):

  Inject
  var greetingService : GreetingService? = null

This of course gives you a nullable GreetingService which is rather annoying as you have to either add nullchecks everywhere or use the !! operator.  I find using constructor injection is much better:

public class HelloController [Inject] ( val greetingService : GreetingService) {

… since you get a non-null reference that doesn’t propagate throughout your code.


#8

Ah! Thanks for that! I think I'd got something similar in the upload controller while experimenting with the injection:

private val lang: Lang by Delegates.lazy {
  val injector = Guice.createInjector(Module())
  injector!!.getInstance(javaClass<Lang>())!!
  }

But it's not anywhere near as tidy.