ninjaframework / ninja Goto Github PK
View Code? Open in Web Editor NEWNinja is a full stack web framework for Java. Rock solid, fast and super productive.
Home Page: http://www.ninjaframework.org
License: Apache License 2.0
Ninja is a full stack web framework for Java. Rock solid, fast and super productive.
Home Page: http://www.ninjaframework.org
License: Apache License 2.0
Otherwise it is not nice to test...
crypto toolkit to sign client side cookie - should allow to automatically invalidate session client side... => save timestamp into cookie...
Like in play1 or in django:
csrf https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-csrf-works
=> a form must have a token that can be validated
=> Gwt resty interface
=> ... more stuff...
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);
}
(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
Demo the writing and reading of databases in project ninja-demo-application-app-engine.
let ninja generate the secret automatically into application.conf
module java missing
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
This code in LangImpl will be not fast:
@OverRide
public Map<Object, Object> getAll(String language) {
Configuration configuration = getLanguageConfigurationForLocale(language);
return ConfigurationConverter.getMap(configuration);
}
Solution 1)
Like exemplified in Play 1 and other frameworks.
Something like
Lang.setLang(en) or so...
To do something like mvn ninja:new
is missing => write one...
Something like Logger().log...
add to documentation that this works nicely and parses json easily: ublic Result postNatureUserIdsAndGetUrls(List postRequestNatureUserIds) {
=> must be there and tested
=> make templating engine exchangable
mvn ninja:run
Using the MessageFormat of ICU for J it should be really
simple to get a perfect i18n plural support...
http://icu-project.org/apiref/icu4j/com/ibm/icu/text/MessageFormat.html
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
Annotate classes with @FilterWith annotation... currently it's only possible on method level
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;
}
}
One for jcache and one for memchached. Should be straight forward. Good examples are Play 1's classes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.