Giter Club home page Giter Club logo

ninja's Introduction

 _______  .___ _______        ____.  _____   
 \      \ |   |\      \      |    | /  _  \  
 /   |   \|   |/   |   \     |    |/  /_\  \ 
/    |    \   /    |    \/\__|    /    |    \
\____|__  /___\____|__  /\________\____|__  /
     web\/framework   \/                  \/ 

Ninja - web framework

Maven Central

Java 8 Java 11 Java 17 Java 19

Ninja is a full stack web framework for Java. Rock solid, fast and super productive.

Getting started

ninja's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ninja's Issues

Class wide filter

Annotate classes with @FilterWith annotation... currently it's only possible on method level

Documentation: Small enhancements

  • messageformat documentation
  • not important for example:
    public Result getCount(Context ctx) {
    return Results.json(count.get());
    }
  • "annotation" is wrong must be validation
    annotation.hasViolations()
  • Write documentation for @required and other stuff...
    @required dokumentieren...

Check if escaped freemarker reader is performant

I guess the streaming and especially the concatenation can be made faster.
Well. it will be cached by Freemarker. Therefore the impact might be minmal

in TemplateEngineFreemarkerEscapedLoader

Improvement: Better and faster parsing of Url paths.

(proposed by James)

Problem: making url parsing better:
which brings us to the topic of ninja... it uses getServletPath() and getPathInfo(), which both return decoded strings, which at some point can/will cause problems

And a close improvement: Use a tree structure
what it should probably do is parse the URI itself, and parse the routes itself, and do segment by segment matching, on decoded segments. this actually would allow a significant performance optimisation too, since, with 60 routes, it won't have to run 60 regular expressions, it can store the routes in a tree structure based on common path segments, and just do equals on those

Content negotiation broken when Result has no content type set.

If the result does not have a content type the type is inferred via:
if (result.getContentType() == null) {
if (context.getRequestContentType() != null) {
result.contentType(context.getRequestContentType());
in ResultHandler.java.

That is wrong as it calls:
return httpServletRequest.getContentType(); in ContextImpl.

this returns the content type.. and that might be text/html; encoding=utf-8 ...
wrong...

better would be to have
context.getAcceptContentType()
context.getAcceptEncoding()

context.getRequestContentType() should be marked as deprecated... or (may be better) documented in a better way... it simply returns the request content type including encoding...

Solution: We have to parse the "Accept" header (case insensitive).

One idea. Play 1 uses the following code that only allows html json xml as content types. Opinionated but makes parsing of the Accept header simple. Source code below.

But there might be better ways to solve this as Ninja potentially allows to support custom content types as well.

    /**
     * Automatically resolve request format from the Accept header
     * (in this order : html > xml > json > text)
     */
    public void resolveFormat() {

        if (format != null) {
            return;
        }

        if (headers.get("accept") == null) {
            format = "html".intern();
            return;
        }

        String accept = headers.get("accept").value();

        if (accept.indexOf("application/xhtml") != -1 || accept.indexOf("text/html") != -1 || accept.startsWith("*/*")) {
            format = "html".intern();
            return;
        }

        if (accept.indexOf("application/xml") != -1 || accept.indexOf("text/xml") != -1) {
            format = "xml".intern();
            return;
        }

        if (accept.indexOf("text/plain") != -1) {
            format = "txt".intern();
            return;
        }

        if (accept.indexOf("application/json") != -1 || accept.indexOf("text/javascript") != -1) {
            format = "json".intern();
            return;
        }

        if (accept.endsWith("*/*")) {
            format = "html".intern();
            return;
        }
    }

Add cache layer support

One for jcache and one for memchached. Should be straight forward. Good examples are Play 1's classes.

Documentation: filter and wrapped context

eg makes a "vanityUrl" filter quite simple to implement

for instance

@OverRide
public Result filter(FilterChain filterChain, Context context) {
return filterChain.next(new WrappedContext(context) {
@OverRide
public String getPathParameter(String key) {
if (USER_ID_SESSION_KEY.equals(key)) {
return username;
} else {
return super.getPathParameter(key);
}

Client side signed cookie support

crypto toolkit to sign client side cookie - should allow to automatically invalidate session client side... => save timestamp into cookie...

Generic renderer support

=> make templating engine exchangable

  • maybe as generic as replacing json with html renderer...

Freemarker rendering => object to map conversion

Add object to map conversion for freemarker...

freemarker itself is a bit picky...

simply use jackson (or beanutils) to convert any object into a map....

=> write an example for content negotiation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.