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
|
<!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%0A%09applications&In-Reply-To=%3C51E7C0A9.8050308%40ninenines.eu%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="000153.html">
<LINK REL="Next" HREF="000154.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[99s-extend] Serve static files with cowboy from some applications</H1>
<B>Loïc Hoguin</B>
<A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20Serve%20static%20files%20with%20cowboy%20from%20some%0A%09applications&In-Reply-To=%3C51E7C0A9.8050308%40ninenines.eu%3E"
TITLE="[99s-extend] Serve static files with cowboy from some applications">essen at ninenines.eu
</A><BR>
<I>Thu Jul 18 12:17:13 CEST 2013</I>
<P><UL>
<LI>Previous message: <A HREF="000153.html">[99s-extend] Serve static files with cowboy from some applications
</A></li>
<LI>Next message: <A HREF="000154.html">[99s-extend] Cowboy handler linked processes
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#155">[ date ]</a>
<a href="thread.html#155">[ thread ]</a>
<a href="subject.html#155">[ subject ]</a>
<a href="author.html#155">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>On 07/17/2013 04:47 PM, Alexander Kuleshov wrote:
><i> Hello,
</I>><i>
</I>><i> 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:
</I>><i>
</I>><i> Dispatch = cowboy_router:compile([
</I>><i> {'_', [
</I>><i> {<<"/static/v/[...]">>, cowboy_static, [
</I>><i> {etag, {attributes, [filepath, filesize, inode, mtime]}},
</I>><i> {mimetypes, [
</I>><i> {<<".js">> , [<<"application/javascript">>]},
</I>><i> {<<".css">>, [<<"text/css">>]},
</I>><i> {<<".gif">>, [<<"image/gif">>]},
</I>><i> {<<".png">>, [<<"image/png">>]},
</I>><i> {<<".jpg">>, [<<"image/jpeg">>]},
</I>><i> {<<".html">>, [<<"text/html">>]}
</I>><i> ]},
</I>><i> {directory, {priv_dir, my_app, [<<"static">>]}}
</I>><i> ]}
</I>><i> ]}
</I>><i> ])
</I>><i>
</I>><i> 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:
</I>><i>
</I>><i> if path /static/v/my_app/index.html than serve index.html from my_app
</I>><i>
</I>><i> if path /static/v/other_app/test.js that serve test.js from other_app.
</I>><i>
</I>><i> and etc....
</I>><i>
</I>><i> Main goal to change: `my_app` from here: {directory, {priv_dir, my_app, [<<"static">>]} dynamically or write custom static handler.
</I>><i>
</I>><i> How to do it correctly with cowboy?
</I>
Why don't you add one rule per application?
--
Loïc Hoguin
Erlang Cowboy
Nine Nines
<A HREF="http://ninenines.eu">http://ninenines.eu</A>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="000153.html">[99s-extend] Serve static files with cowboy from some applications
</A></li>
<LI>Next message: <A HREF="000154.html">[99s-extend] Cowboy handler linked processes
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#155">[ date ]</a>
<a href="thread.html#155">[ thread ]</a>
<a href="subject.html#155">[ subject ]</a>
<a href="author.html#155">[ author ]</a>
</LI>
</UL>
<hr>
<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend
mailing list</a><br>
</body></html>
|