Package com.mastfrog.acteur
Class ActeurFactory
java.lang.Object
com.mastfrog.acteur.ActeurFactory
Factory for standard Acteur implementations, mainly used to determine if a
request is valid (matches a URL, is using a supported HTTP method, etc.).
Usage model: Ask for this in your
Page constructor and use it to add
acteurs.
Almost all methods on this class can be used via annotations, so using
this class directly is rare post Acteur 1.4.- Author:
- Tim Boudreau
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA test which can be performed on a request, for example, to decide about branching -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbanParameters(String... names) Reject request which contain the passed parametersexactPathLength(int length) globPathMatch(boolean decode, String... patterns) globPathMatch(String... patterns) <T> ActeurinjectRequestBodyAsJSON(Class<T> type) Creates an Acteur which will read the request body, construct an object from it, and include it for injection into later Acteurs in the chain.<T> ActeurinjectRequestParametersAs(Class<T> type) Create an acteur which will take the request parameters, turn them into an implementation of some interface and include that in the set of objects later Acteurs in the chain can request for injection.matchMethods(boolean notSupp, Method... methods) Reject the request if it is not an allowed HTTP method, optionally including information in the response, or simply rejecting the request and allowing the next page a crack at it.matchMethods(Method... methods) Deprecated.Use @Methods instead - it is self-documentingDeprecated.Deprecated.Use @PathRegex instead - it is self-documentingmaximumBodyLength(int length) maximumPathLength(int length) minimumBodyLength(int length) minimumPathLength(int length) parametersMayNotBeCombined(String... names) parametersMustBeNumbersIfTheyArePresent(boolean allowDecimal, boolean allowNegative, String... names) Check the "If-Unmodified-Since" headerrequireAtLeastOneParameter(String... names) Reject the request if none of the passed parameter names are presentrequireParameters(String... names) Reject the request unless certain URL parameters are presentrequireParametersIfMethodMatches(Method method, String... params) respondWith(int status) respondWith(int status, String msg) respondWith(io.netty.handler.codec.http.HttpResponseStatus status) respondWith(io.netty.handler.codec.http.HttpResponseStatus status, String msg) responseCode(io.netty.handler.codec.http.HttpResponseStatus status) Create an Acteur which simply always responds with the given HTTP status.Checks the IF_NONE_MATCH header and compares it with the value from the current Page's getETag() method.Check the "If-Modified-Since" header and compares it to the current Page's getLastModified (rounding milliseconds down).
-
Constructor Details
-
ActeurFactory
@Inject public ActeurFactory()
-
-
Method Details
-
matchMethods
Deprecated.Use @Methods instead - it is self-documentingReject the request if it is not one of the passed HTTP methods- Parameters:
methods- Methods- Returns:
- An Acteur that can be used in a page
-
matchMethods
Reject the request if it is not an allowed HTTP method, optionally including information in the response, or simply rejecting the request and allowing the next page a crack at it.- Parameters:
notSupp- If true, respond with METHOD_NOT_ALLOWED and the ALLOW header setmethods- The http methods which are allowed- Returns:
- An Acteur
-
exactPathLength
-
minimumPathLength
-
maximumPathLength
-
redirect
- Throws:
URISyntaxException
-
redirect
public Acteur redirect(String location, io.netty.handler.codec.http.HttpResponseStatus status) throws URISyntaxException - Throws:
URISyntaxException
-
injectRequestBodyAsJSON
Creates an Acteur which will read the request body, construct an object from it, and include it for injection into later Acteurs in the chain.- Type Parameters:
T-- Parameters:
type- The object type- Returns:
- An acteur
-
injectRequestParametersAs
Create an acteur which will take the request parameters, turn them into an implementation of some interface and include that in the set of objects later Acteurs in the chain can request for injection. Note that you may need to include the type in your application's@ImplicitBindingsannotation for Guice to allow your type to be injected. The type must be an interface type, and its methods should correspond exactly to the parameter names desired. -
responseCode
Create an Acteur which simply always responds with the given HTTP status.- Parameters:
status- A status- Returns:
- An acteur
-
requireParameters
Reject the request unless certain URL parameters are present- Parameters:
names- The parameter names- Returns:
- An acteur
-
parametersMayNotBeCombined
-
parametersMustBeNumbersIfTheyArePresent
-
banParameters
Reject request which contain the passed parameters- Parameters:
names- A list of parameter names for the URL- Returns:
- An acteur
-
requireAtLeastOneParameter
Reject the request if none of the passed parameter names are present- Parameters:
names-- Returns:
-
matchPath
Deprecated.Use @PathRegex instead - it is self-documentingReject the request if HttpEvent.path().toString() does not match one of the passed regular expressions- Parameters:
regexen- Regexen- Returns:
- An acteur
-
matchPath
Deprecated. -
sendNotModifiedIfETagHeaderMatches
Checks the IF_NONE_MATCH header and compares it with the value from the current Page's getETag() method. If it matches, forces a NOT_MODIFIED http response and ends processing of the chain of Acteurs.- Returns:
- An acteur
-
sendNotModifiedIfETagHeaderMatchesType
-
globPathMatch
-
globPathMatch
-
sendNotModifiedIfIfModifiedSinceHeaderMatches
Check the "If-Modified-Since" header and compares it to the current Page's getLastModified (rounding milliseconds down). If the condition is met, responds with NOT_MODIFIED.- Returns:
- an Acteur
-
sendNotModifiedIfIfModifiedSinceHeaderMatchesType
-
preconditionFailedIfUnmodifiedSinceMatches
Check the "If-Unmodified-Since" header- Returns:
- an Acteur
-
preconditionFailedIfUnmodifiedSinceMatchesType
-
respondWith
-
respondWith
-
respondWith
-
respondWith
-
minimumBodyLength
-
maximumBodyLength
-
requireParametersIfMethodMatches
-
redirectEmptyPath
- Throws:
URISyntaxException
-
redirectEmptyPath
- Throws:
URISyntaxException
-
branch
-