Some content


Any @Web***Handler and @WebGet, @WebPost, @WebDelete, @WebPut methods have dynamic signature, meaning that they can have any number of arguments, and Snow will inject the appropriate values based on the HTTP request.

Snow will resolve the value of each method argument based on argument type and annotation with a process called WebParamResolver. Snow provides default WebParamResolvers, but more importantly, makes it dead simple (and flexible) to develop custom WebParamResolvers.

Also, as of Snow 2.0.0, if no default or custom param resolver is found for a parameter type, Snow will attempt to resolve the parameter type with Googe Guice. This allows to inject Guice binded type in any @Web[REST] or @Web[Model|Resource]Handler.

Default Web Param Resolvers

Here are the default Web Param annotation and types Snow provides out of the box.

@WebParam for Primitive Types

Primitive types (String, Long, Integer, Double, Boolean) with @WebParam([paramName]) will have their string value converted to the target type (if failed or absent, null will be set)

public Object processCard(@WebParam("Full Name")String fullName, 
                        @WebParam("expirationMonth")Integer xpMonth,
                        @WebParam("expirationYear")Integer xpYear, 
                        @WebParam("isCredit")Boolean isCredit,
                        @WebParam("cardNum")Long cardNum){
    // some super secure processing (hopefully)                                

@PathVar (only for @Web[REST]) (since 2.0.0)

For @WebGet, @WebPost, @WebDelete, and @WebPut method parameter can be annotated with @PathVar which get a path variable from the "{.}" notation.

public Object deleteItem(@PathVar("id")Long id){
  // for URI as "/api/delete-123" id == 123L


Annotating a WebHandler method argument with @WebModel will inject the WebModel of the request, which is the Map that will be used for the templating or json serialization.

Usually, @WebModel are used in WebModelHandlers since their primary focus is to populate the WebModel Map.

public void contactList(@WebModel Map webModel,@WebParam("circleId")Long circleId){
  // Assuming this Class as a DAO for circle (probably injected with @Inject) 
  List<Contact> contactList = circleDao.getCircleById(circleId).getContactList();
  // We populate the @WebModel Map with the contactList property

Note This is the equivalent of doing requestContext.getWebModel(), but allow to have a cleaner (RequestContext free) WebHandler method signature.


When necessary, the WebHandler method might need the full request information, and for this, it is as simple as adding a RequestContext argument

public void complexInfo(RequestContext rc){
  Map webModel = rc.getWebModel();
  HttpServletRequest httpRequest = rc.getReq();
  HttpServletRequest httpResponse = rc.getRes();
  // Note: all these three values could be injected as well


@WebPath is a convenient WebParam annotation to get the value of a path at a given index.

Let say that we have the following HTTP-GET, where a variable is in the path rather than the request parameter.

HTTP-GET /contact/123?data=info

Then, we could use similar parameter facilities, using the @WebPath argument

public void contactPage(@WebModel Map m, @WebPath(1)Long userId,
                     @WebParam("data") dataType) {
  // here, userId == 123


Assuming you have implemented an AuthService and a Login @WebActioHandler, the @WebUser annotation will tell Snow to inject the User

public Object contactListPage(@WebUser User user,
                            /* other param */){
  // Note that "User.class" is the application user class, 
  // what was created in the AuthService (Snow does not have any User class)

HttpServletRequest, HttpServletResponse, ServletContext

While not recommended, you can also inject HttpServletRequest, HttpServletResponse, ServletContext if you really need so.

public void exportToPdf(HttpServletRequest req, HttpServletResponse res, 
                        ServletContext sc){
  // some pretty nifty logic to export some content to pdf.                          


Snow supports transparent fileUpload, meaning, you do not have to do anything special to get uploaded files.

Under the cover Snow use Apache FileUpload, and so, the way to get a File uploaded in your WebHandler method is to ask for the FileItem type

public void saveContactInfo(@WebParam("profileImage")FileItem profileImageFileItem, 
                            @WebParam("fullName") String fullName){
      // user the Apache FileUpload FileItem API