1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE> [99s-extend] Serve static files with cowboy from some applications
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20Serve%20static%20files%20with%20cowboy%20from%20some%20applications&In-Reply-To=%3C1124365136.645865.1374072463432.JavaMail.root%40tpip.net%3E">
<META NAME="robots" CONTENT="index,nofollow">
<style type="text/css">
pre {
white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
}
</style>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="000152.html">
<LINK REL="Next" HREF="000155.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[99s-extend] Serve static files with cowboy from some applications</H1>
<B>Alexander Kuleshov</B>
<A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20Serve%20static%20files%20with%20cowboy%20from%20some%20applications&In-Reply-To=%3C1124365136.645865.1374072463432.JavaMail.root%40tpip.net%3E"
TITLE="[99s-extend] Serve static files with cowboy from some applications">akuleshov at tpip.net
</A><BR>
<I>Wed Jul 17 16:47:43 CEST 2013</I>
<P><UL>
<LI>Previous message: <A HREF="000152.html">[99s-extend] Cowboy: http request maximum body size
</A></li>
<LI>Next message: <A HREF="000155.html">[99s-extend] Serve static files with cowboy from some applications
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#153">[ date ]</a>
<a href="thread.html#153">[ thread ]</a>
<a href="subject.html#153">[ subject ]</a>
<a href="author.html#153">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Hello,
I have a web application which used cowboy (from master). I need to serve some static files, it's usual web application but i can use usual dispatch something like this:
Dispatch = cowboy_router:compile([
{'_', [
{<<"/static/v/[...]">>, cowboy_static, [
{etag, {attributes, [filepath, filesize, inode, mtime]}},
{mimetypes, [
{<<".js">> , [<<"application/javascript">>]},
{<<".css">>, [<<"text/css">>]},
{<<".gif">>, [<<"image/gif">>]},
{<<".png">>, [<<"image/png">>]},
{<<".jpg">>, [<<"image/jpeg">>]},
{<<".html">>, [<<"text/html">>]}
]},
{directory, {priv_dir, my_app, [<<"static">>]}}
]}
]}
])
And i try to explain why. In fact, i have one application (this application) which used cowboy and many plugins for it. Every plugin is an erlang application and also every application has own static files. I need routing something like this:
if path /static/v/my_app/index.html than serve index.html from my_app
if path /static/v/other_app/test.js that serve test.js from other_app.
and etc....
Main goal to change: `my_app` from here: {directory, {priv_dir, my_app, [<<"static">>]} dynamically or write custom static handler.
How to do it correctly with cowboy?
Thank you.
--
Alex Kuleshov
Software Developer
email: <A HREF="https://lists.ninenines.eu/listinfo/extend">ak at travelping.com</A>
phone: +77172227194
mobile: +77019442517
----------------- enabling your networks ---------------------
Travelping GmbH phone: +49-391-8190990
Roentgenstr. 13 fax: +49-391-819099299
D-39108 Magdeburg email: <A HREF="https://lists.ninenines.eu/listinfo/extend">info at travelping.com</A>
GERMANY web: <A HREF="http://www.travelping.com">http://www.travelping.com</A>
Company Registration: Amtsgericht Stendal Reg No.: HRB 10578
Geschaeftsfuehrer: Holger Winkelmann | VAT ID No.: DE236673780
--------------------------------------------------------------
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="000152.html">[99s-extend] Cowboy: http request maximum body size
</A></li>
<LI>Next message: <A HREF="000155.html">[99s-extend] Serve static files with cowboy from some applications
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#153">[ date ]</a>
<a href="thread.html#153">[ thread ]</a>
<a href="subject.html#153">[ subject ]</a>
<a href="author.html#153">[ author ]</a>
</LI>
</UL>
<hr>
<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend
mailing list</a><br>
</body></html>
|