Package ratpack.groovy.handling
Interface GroovyByContentSpec
-
- All Superinterfaces:
ByContentSpec
- All Known Implementing Classes:
DefaultGroovyByContentSpec
public interface GroovyByContentSpec extends ByContentSpec
A Groovy oriented content negotiation handler builder.- Since:
- 1.5
- See Also:
GroovyContext.byMethod(Closure)
,ByMethodSpec
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default GroovyByContentSpec
html(Closure<?> handler)
Specifies that the given handler should be used if the client wants content of type "text/html".GroovyByContentSpec
html(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of type "text/html".GroovyByContentSpec
html(Handler handler)
Specifies that the given handler should be used if the client wants content of type "text/html".GroovyByContentSpec
html(Block block)
Specifies that the given handler should be used if the client wants content of type "text/html".default GroovyByContentSpec
json(Closure<?> handler)
Specifies that the given handler should be used if the client wants content of type "application/json".GroovyByContentSpec
json(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of type "application/json".GroovyByContentSpec
json(Handler handler)
Specifies that the given handler should be used if the client wants content of type "application/json".GroovyByContentSpec
json(Block block)
Specifies that the given handler should be used if the client wants content of type "application/json".default GroovyByContentSpec
noMatch(Closure<?> handler)
Specifies that the given handler should be used if the client's requested content type cannot be matched with any of the other handlers.GroovyByContentSpec
noMatch(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client's requested content type cannot be matched with any of the other handlers.GroovyByContentSpec
noMatch(String mimeType)
Specifies that the handler for the specified content type should be used if the client's requested content type cannot be matched with any of the other handlers.GroovyByContentSpec
noMatch(Handler handler)
Specifies that the given handler should be used if the client's requested content type cannot be matched with any of the other handlers.GroovyByContentSpec
noMatch(Block block)
Specifies that the given handler should be used if the client's requested content type cannot be matched with any of the other handlers.default GroovyByContentSpec
plainText(Closure<?> handler)
Specifies that the given handler should be used if the client wants content of type "text/plain".GroovyByContentSpec
plainText(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of type "text/plain".GroovyByContentSpec
plainText(Handler handler)
Specifies that the given handler should be used if the client wants content of type "text/plain".GroovyByContentSpec
plainText(Block block)
Specifies that the given handler should be used if the client wants content of type "text/plain".default GroovyByContentSpec
type(CharSequence mimeType, Closure<?> handler)
Specifies that the given handler should be used if the client wants content of the given MIME type.GroovyByContentSpec
type(CharSequence mimeType, Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of the given MIME type.GroovyByContentSpec
type(CharSequence mimeType, Handler handler)
Specifies that the given handler should be used if the client wants content of the given MIME type.GroovyByContentSpec
type(CharSequence mimeType, Block block)
Specifies that the given handler should be used if the client wants content of the given MIME type.default GroovyByContentSpec
type(String mimeType, Closure<?> handler)
Specifies that the given handler should be used if the client wants content of the given MIME type.GroovyByContentSpec
type(String mimeType, Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of the given MIME type.GroovyByContentSpec
type(String mimeType, Handler handler)
Specifies that the given handler should be used if the client wants content of the given MIME type.GroovyByContentSpec
type(String mimeType, Block block)
Specifies that the given handler should be used if the client wants content of the given MIME type.default GroovyByContentSpec
unspecified(Closure<?> handler)
Specifies that the given handler should be used if the client did not provide a usable "Accept" header in the request.GroovyByContentSpec
unspecified(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client did not provide a usable "Accept" header in the request.GroovyByContentSpec
unspecified(String mimeType)
Specifies that the handler for the specified content type should be used if the client did not provide a usable "Accept" header in the request.GroovyByContentSpec
unspecified(Handler handler)
Specifies that the given handler should be used if the client did not provide a usable "Accept" header in the request.GroovyByContentSpec
unspecified(Block block)
Specifies that the given handler should be used if the client did not provide a usable "Accept" header in the request.default GroovyByContentSpec
xml(Closure<?> handler)
Specifies that the given handler should be used if the client wants content of type "application/xml".GroovyByContentSpec
xml(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of type "application/xml".GroovyByContentSpec
xml(Handler handler)
Specifies that the given handler should be used if the client wants content of type "application/xml".GroovyByContentSpec
xml(Block block)
Specifies that the given handler should be used if the client wants content of type "application/xml".
-
-
-
Method Detail
-
type
default GroovyByContentSpec type(String mimeType, @DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Specifies that the given handler should be used if the client wants content of the given MIME type. This only supports fully-specified content types (no "*" wildcards).- Parameters:
mimeType
- the MIME type to register forhandler
- the handler to invoke if the content type matches- Returns:
- this
-
type
default GroovyByContentSpec type(CharSequence mimeType, @DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Specifies that the given handler should be used if the client wants content of the given MIME type. This only supports fully-specified content types (no "*" wildcards).- Parameters:
mimeType
- the MIME type to register forhandler
- the handler to invoke if the content type matches- Returns:
- this
- Since:
- 1.6
-
plainText
default GroovyByContentSpec plainText(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Specifies that the given handler should be used if the client wants content of type "text/plain".- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
html
default GroovyByContentSpec html(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Specifies that the given handler should be used if the client wants content of type "text/html".- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
json
default GroovyByContentSpec json(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Specifies that the given handler should be used if the client wants content of type "application/json".- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
xml
default GroovyByContentSpec xml(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Specifies that the given handler should be used if the client wants content of type "application/xml".- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
noMatch
default GroovyByContentSpec noMatch(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Specifies that the given handler should be used if the client's requested content type cannot be matched with any of the other handlers.- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
unspecified
default GroovyByContentSpec unspecified(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Specifies that the given handler should be used if the client did not provide a usable "Accept" header in the request.- Parameters:
handler
- the handler to invoke if if no usable "Accept" header is present in the request.- Returns:
- this
-
type
GroovyByContentSpec type(String mimeType, Block block)
Specifies that the given handler should be used if the client wants content of the given MIME type. This only supports fully-specified content types (no "*" wildcards).- Specified by:
type
in interfaceByContentSpec
- Parameters:
mimeType
- the MIME type to register forblock
- the code to invoke if the content type matches- Returns:
- this
-
type
GroovyByContentSpec type(CharSequence mimeType, Block block)
Specifies that the given handler should be used if the client wants content of the given MIME type. This only supports fully-specified content types (no "*" wildcards).- Specified by:
type
in interfaceByContentSpec
- Parameters:
mimeType
- the MIME type to register forblock
- the code to invoke if the content type matches- Returns:
- this
-
type
GroovyByContentSpec type(String mimeType, Handler handler)
Specifies that the given handler should be used if the client wants content of the given MIME type. This only supports fully-specified content types (no "*" wildcards).- Specified by:
type
in interfaceByContentSpec
- Parameters:
mimeType
- the MIME type to register forhandler
- the handler to invoke if the content type matches- Returns:
- this
-
type
GroovyByContentSpec type(CharSequence mimeType, Handler handler)
Specifies that the given handler should be used if the client wants content of the given MIME type. This only supports fully-specified content types (no "*" wildcards).- Specified by:
type
in interfaceByContentSpec
- Parameters:
mimeType
- the MIME type to register forhandler
- the handler to invoke if the content type matches- Returns:
- this
-
type
GroovyByContentSpec type(String mimeType, Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of the given MIME type. This only supports fully-specified content types (no "*" wildcards).- Specified by:
type
in interfaceByContentSpec
- Parameters:
mimeType
- the MIME type to register forhandlerType
- the type of handler to retrieve from the registry and use- Returns:
- this
-
type
GroovyByContentSpec type(CharSequence mimeType, Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of the given MIME type. This only supports fully-specified content types (no "*" wildcards).- Specified by:
type
in interfaceByContentSpec
- Parameters:
mimeType
- the MIME type to register forhandlerType
- the type of handler to retrieve from the registry and use- Returns:
- this
-
plainText
GroovyByContentSpec plainText(Block block)
Specifies that the given handler should be used if the client wants content of type "text/plain".- Specified by:
plainText
in interfaceByContentSpec
- Parameters:
block
- the code to invoke if the content type matches- Returns:
- this
-
plainText
GroovyByContentSpec plainText(Handler handler)
Specifies that the given handler should be used if the client wants content of type "text/plain".- Specified by:
plainText
in interfaceByContentSpec
- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
plainText
GroovyByContentSpec plainText(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of type "text/plain".- Specified by:
plainText
in interfaceByContentSpec
- Parameters:
handlerType
- the type of handler to retrieve from the registry and use- Returns:
- this
-
html
GroovyByContentSpec html(Block block)
Specifies that the given handler should be used if the client wants content of type "text/html".- Specified by:
html
in interfaceByContentSpec
- Parameters:
block
- the code to invoke if the content type matches- Returns:
- this
-
html
GroovyByContentSpec html(Handler handler)
Specifies that the given handler should be used if the client wants content of type "text/html".- Specified by:
html
in interfaceByContentSpec
- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
html
GroovyByContentSpec html(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of type "text/html".- Specified by:
html
in interfaceByContentSpec
- Parameters:
handlerType
- the type of handler to retrieve from the registry and use- Returns:
- this
-
json
GroovyByContentSpec json(Block block)
Specifies that the given handler should be used if the client wants content of type "application/json".- Specified by:
json
in interfaceByContentSpec
- Parameters:
block
- the code to invoke if the content type matches- Returns:
- this
-
json
GroovyByContentSpec json(Handler handler)
Specifies that the given handler should be used if the client wants content of type "application/json".- Specified by:
json
in interfaceByContentSpec
- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
json
GroovyByContentSpec json(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of type "application/json".- Specified by:
json
in interfaceByContentSpec
- Parameters:
handlerType
- the type of handler to retrieve from the registry and use- Returns:
- this
-
xml
GroovyByContentSpec xml(Block block)
Specifies that the given handler should be used if the client wants content of type "application/xml".- Specified by:
xml
in interfaceByContentSpec
- Parameters:
block
- the code to invoke if the content type matches- Returns:
- this
-
xml
GroovyByContentSpec xml(Handler handler)
Specifies that the given handler should be used if the client wants content of type "application/xml".- Specified by:
xml
in interfaceByContentSpec
- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
xml
GroovyByContentSpec xml(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client wants content of type "application/xml".- Specified by:
xml
in interfaceByContentSpec
- Parameters:
handlerType
- the type of handler to retrieve from the registry and use- Returns:
- this
-
noMatch
GroovyByContentSpec noMatch(Block block)
Specifies that the given handler should be used if the client's requested content type cannot be matched with any of the other handlers.- Specified by:
noMatch
in interfaceByContentSpec
- Parameters:
block
- the code to invoke if the content type doesn't match- Returns:
- this
-
noMatch
GroovyByContentSpec noMatch(Handler handler)
Specifies that the given handler should be used if the client's requested content type cannot be matched with any of the other handlers.- Specified by:
noMatch
in interfaceByContentSpec
- Parameters:
handler
- the handler to invoke if the content type matches- Returns:
- this
-
noMatch
GroovyByContentSpec noMatch(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client's requested content type cannot be matched with any of the other handlers.- Specified by:
noMatch
in interfaceByContentSpec
- Parameters:
handlerType
- the type of handler to retrieve from the registry and use- Returns:
- this
-
noMatch
GroovyByContentSpec noMatch(String mimeType)
Specifies that the handler for the specified content type should be used if the client's requested content type cannot be matched with any of the other handlers. Effectively, this treats the request as if the user requested the specified MIME type. If the specified mimeType doesn't have a registered block, it will result in a server error for applicable requests.- Specified by:
noMatch
in interfaceByContentSpec
- Parameters:
mimeType
- the MIME type to use as a fallback if the requested type can't be matched- Returns:
- this
-
unspecified
GroovyByContentSpec unspecified(Block block)
Specifies that the given handler should be used if the client did not provide a usable "Accept" header in the request.- Specified by:
unspecified
in interfaceByContentSpec
- Parameters:
block
- the code to invoke if no usable "Accept" header is present in the request.- Returns:
- this
-
unspecified
GroovyByContentSpec unspecified(Handler handler)
Specifies that the given handler should be used if the client did not provide a usable "Accept" header in the request.- Specified by:
unspecified
in interfaceByContentSpec
- Parameters:
handler
- the handler to invoke if if no usable "Accept" header is present in the request.- Returns:
- this
-
unspecified
GroovyByContentSpec unspecified(Class<? extends Handler> handlerType)
Specifies that the given handler should be used if the client did not provide a usable "Accept" header in the request.- Specified by:
unspecified
in interfaceByContentSpec
- Parameters:
handlerType
- the type of handler to retrieve from the registry and use if no usable "Accept" header is present in the request.- Returns:
- this
-
unspecified
GroovyByContentSpec unspecified(String mimeType)
Specifies that the handler for the specified content type should be used if the client did not provide a usable "Accept" header in the request. Effectively, this treats the request as if the user requested the specified MIME type. If the specified mimeType doesn't have a registered block, it will result in a server error for applicable requests.- Specified by:
unspecified
in interfaceByContentSpec
- Parameters:
mimeType
- the MIME type to use as a fallback if no type is requested- Returns:
- this
-
-