You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
convert parameters, headers and cookies to typed method arguments
convert method return types to response body
map from and to types respecting the given or requested media types (media type dispatch)
user auth (redirect to login)
error handling (redirect to error page)
Techniques to solve them
use lambdas to avoid need to bind to specific annotations (or annotations at all)
dispatch by semantic (while one method implements a specific URL the dispatch might be dynamic. One task is to find out what method to use for a URL, another is to map the request to the args and the return value to result body. keep these 3 independent)
To make foreign annotations work they could be bound to a HTTP concept like this:
path(RequestMapping.class, a -> a.path());
param(RequestParam.class, a -> a.value());
param(PathVariable.class, a -> '{'+ a.value() + ''});
auth(Role.class, a -> a.requires());
controller(Web.class);
Variables in a path are expected as {var-name}. If a param mapping returns a name with {...} it means a path var is meant so we add the curly brackets back to the name given in the annotation.
Using fix path patterns is only the default strategy to map paths to methods. It uses the annotation bound for path to extract the path pattern which also is the methods uniqueId by which mapping is done.
interfacePathStrategy {
StringuniqueId(MethodwebMethod); // returns null if it is not a web method
}
silk-web contains such a service hook file. It will then load web.java (in default package) where initialization of the web application is given or referenced.
The text was updated successfully, but these errors were encountered:
Problems that would be solved by silk web
Techniques to solve them
To make foreign annotations work they could be bound to a HTTP concept like this:
Variables in a path are expected as
{var-name}
. If aparam
mapping returns a name with{...}
it means a path var is meant so we add the curly brackets back to the name given in the annotation.Using fix path patterns is only the default strategy to map paths to methods. It uses the annotation bound for
path
to extract the path pattern which also is the methodsuniqueId
by which mapping is done.also:
Hooking into Servlet container
Spring hooks into servlet API.
as described here
https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/spring-mvc-intro.html
Spring being spring this is a layer on top of actual servlet API as described here https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/SpringServletContainerInitializer.html
The servlet API mechanism is called
ServletContainerInitializer
, see http://docs.jboss.org/jbossas/javadoc/7.1.2.Final/javax/servlet/ServletContainerInitializer.htmlsilk-web contains such a service hook file. It will then load
web.java
(in default package) where initialization of the web application is given or referenced.The text was updated successfully, but these errors were encountered: