Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixes file handling loading form the priv folder

  • Loading branch information...
commit a5959b4da5480e8b1bd362b22cec6a7250f4e741 1 parent dd2d5db
Alvaro Videla authored May 15, 2011

Showing 1 changed file with 16 additions and 4 deletions. Show diff stats Hide diff stats

  1. 20  src/rabbit_websockets_worker.erl
20  src/rabbit_websockets_worker.erl
@@ -71,20 +71,32 @@ handle('HEAD', [], #http_state{req=Req}) ->
71 71
     Req:ok("");
72 72
 
73 73
 handle('GET', [], #http_state{req=Req}) ->
74  
-    Req:file("./priv/www/index.html", [{"Content-Type", "text/html"}]);
  74
+    Req:file(filename:join(web_root(), "index.html"), [{"Content-Type", "text/html"}]);
  75
+
  76
+handle('GET', ["index.html"], #http_state{req=Req}) ->
  77
+    Req:file(filename:join(web_root(), "index.html"), [{"Content-Type", "text/html"}]);
75 78
 
76 79
 handle('GET',["favicon.ico"], #http_state{req=Req}) ->
77  
-    Req:file("./priv/www/favicon.ico", [{"Content-Type", "image/vnd.microsoft.icon"}]);
  80
+    Req:file(filename:join(web_root(), "favicon.ico"), [{"Content-Type", "image/vnd.microsoft.icon"}]);
78 81
 
79 82
 handle('GET', ["js", FileName], #http_state{req=Req}) ->
80  
-    Req:file(filename:join("./priv/www/js/", FileName), [{"Content-Type", "text/javascript"}]);
  83
+    Req:file(filename:join(js_root(), FileName), [{"Content-Type", "text/javascript"}]);
81 84
 
82 85
 handle('GET', ["css", FileName], #http_state{req=Req}) ->
83  
-    Req:file(filename:join("./priv/www/css/", FileName), [{"Content-Type", "text/css"}]);
  86
+    Req:file(filename:join(css_root(), FileName), [{"Content-Type", "text/css"}]);
84 87
 
85 88
 handle(_, _, #http_state{req=Req}) ->
86 89
     Req:ok([{"Content-Type", "text/plain"}], "Page not found.").
87 90
 
  91
+web_root() ->
  92
+    filename:join(code:priv_dir(rabbitmq_websockets), "www").
  93
+
  94
+js_root() ->
  95
+    filename:join(web_root(), "js").
  96
+
  97
+css_root() ->
  98
+    filename:join(web_root(), "css").
  99
+
88 100
 %-----------------------------------
89 101
 % Websockets Handling Implementation
90 102
 % ----------------------------------

0 notes on commit a5959b4

Please sign in to comment.
Something went wrong with that request. Please try again.