HttpRequest

public class HttpRequest extends DefaultFullHttpRequest

Class to access the request details. This class inherits from netty’s DefaultFullHttpRequest

See also: DefaultFullHttpRequest

Fields

auth

Auth auth

dbSession

int dbSession

params

Map<String, List<String>> params

path

String path

routeMatch

RouteMatch routeMatch

staticFileName

String staticFileName

staticUrlResource

String staticUrlResource

userPermissions

HashSet<Integer> userPermissions

Constructors

HttpRequest

public HttpRequest(HttpVersion httpVersion, HttpMethod method, String uri, ByteBuf content)

Application code will not have any use with the constructors as the application code will always process on an initialized request object.

HttpRequest

public HttpRequest(FullHttpRequest req)

Methods

auth

public Auth auth()

Returns the auth object of this request.

getStaticFile

public String getStaticFile()

Get the static file set in this request

Returns:The resource’s absolute file path

getStaticUrlResource

public String getStaticUrlResource()

Get the static resource set in this request

Returns:The resource name

methodName

public String methodName()

Get the HTTP method

Returns:String name of the method

params

public Map<String, List<String>> params()

Returns the URL parameters.

Returns:Map of string to list of strings - with the key being the parameter name and value being the parameter value.

path

public String path()

Returns the URL path, example, for url GET /aalam/base/users?param1=value&param2=value, the path will be /aalam/base/users

Returns:String value of the path

routeMatch

public RouteMatch routeMatch()

Application will have no use with this method. this method will be used by the framework internally.

setAnonymousAuth

public void setAnonymousAuth()

This method will be used by the framework internally.

setCookieAuth

public void setCookieAuth(String email, Integer userId)

This method will be used by the framework internally.

setCookieAuth

public void setCookieAuth(String email)

This method will be used by the framework internally.

setExternalAuth

public void setExternalAuth(String from)

This method will be used by the framework internally.

setExternalAuth

public void setExternalAuth(String from, String userEmail, Integer id)

This method will be used by the framework internally.

setInternalAuth

public void setInternalAuth(String from, String userEmail)

This method will be used by the framework internally.

setRouteMatch

public void setRouteMatch(RouteMatch obj)

Application will have no use with this method. this method will be used by the framework internally.

setStaticInfo

public void setStaticInfo(String resource, String file)

Though applications can pre-inform the static URL and the way to access the static data through build plugin, there might be some situation which would want to send a static file on a non-static URL. For example, if an application has a static-url prefix as /aalam/base/s/. Suppose the application wants to serve a static file in a URL that does not have a prefix /aalam/base/s/, or if the file is not on the usual place that the framework can find, it can inform the framework about this static resource through this method This method needs to be called in the action handler. By doing so, the framework will take care of sending the response.

Parameters:
  • resource – A unique name of this resource. This name should not clash with any of the other static resources.
  • file – The path to the resource

setTokenAuth

public void setTokenAuth(String appId)

This method will be used by the framework internally.

setUserPermissions

public void setUserPermissions(HashSet<Integer> permissions)

Application will have no use with this method. this method will be used by the framework internally.

userPermissions

public HashSet<Integer> userPermissions()

Get the permissions of the user initiating this request

Returns:Set of permission ids.