Skip to content

Commit

Permalink
handle web request for resources in the tiled or data folder
Browse files Browse the repository at this point in the history
  • Loading branch information
nhnb committed May 29, 2011
1 parent 9ca000f commit 8358686
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/games/stendhal/server/core/engine/StendhalRPRuleProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -717,4 +717,34 @@ public void removeZone(final StendhalRPZone zone) {
public static void setWelcomeMessage(String msg) {
StendhalRPRuleProcessor.welcomeMessage = msg;
}

/**
* gets the content type for the requested resource
*
* @param resource name of resource
* @return mime content/type or <code>null</code>
*/
public String getMimeTypeForResource(String resource) {
if (resource.endsWith(".tmx")) {
return "text/xml";
} else if (resource.endsWith(".tmx")) {
return "audio/ogg";
} else if (resource.endsWith(".png")) {
return "image/png";
}
return null;
}

/**
* gets an input stream to the requested resource
*
* @param resource name of resource
* @return InputStream or <code>null</code>
*/
public InputStream getResource(String resource) {
if (resource.startsWith("/tiled") || resource.startsWith("/data")) {
return StendhalRPRuleProcessor.class.getClassLoader().getResourceAsStream(resource.substring(1));
}
return null;
}
}

0 comments on commit 8358686

Please sign in to comment.