Skip to content

Commit

Permalink
o add content-type parameter to content behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
nabcos committed Nov 23, 2011
1 parent f05816e commit a1618d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Expand Up @@ -37,4 +37,9 @@ public static Content content( String content )
return Content.content( content );
}

public static Content content( String content, String type )
{
return Content.content( content, type );
}

}
Expand Up @@ -22,26 +22,38 @@

/**
* @author Benjamin Hanzelmann
*
*/
public class Content
implements Behaviour
{

private String content;

public static Content content(String content)
private String type;

public static Content content( String content )
{
return new Content( content );
}

public static Content content( String content, String type )
{
return new Content( content, type );
}

public Content()
{
}

public Content( String content )
{
this( content, "text/plain" );
}

public Content( String content, String type )
{
this.content = content;
this.type = type;
}

public boolean execute( HttpServletRequest request, HttpServletResponse response, Map<Object, Object> ctx )
Expand All @@ -51,7 +63,7 @@ public boolean execute( HttpServletRequest request, HttpServletResponse response
String content = path;
if ( "GET".equals( request.getMethod() ) )
{
response.setContentType( "text/plain" );
response.setContentType( type );
if ( this.content != null )
{
content = this.content;
Expand Down

0 comments on commit a1618d1

Please sign in to comment.