summaryrefslogblamecommitdiffstats
path: root/archives/extend/2013-July/000155.html
blob: 881c8ddcaffe54de77d21983748a97ac6f172c2f (plain) (tree)





































































































                                                                                                                                                                                                                                                              
<!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&#239;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:
&gt;<i> Hello,
</I>&gt;<i>
</I>&gt;<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>&gt;<i>
</I>&gt;<i>      Dispatch = cowboy_router:compile([
</I>&gt;<i>          {'_', [
</I>&gt;<i>                  {&lt;&lt;&quot;/static/v/[...]&quot;&gt;&gt;, cowboy_static, [
</I>&gt;<i>                      {etag, {attributes, [filepath, filesize, inode, mtime]}},
</I>&gt;<i>                      {mimetypes, [
</I>&gt;<i>                              {&lt;&lt;&quot;.js&quot;&gt;&gt; , [&lt;&lt;&quot;application/javascript&quot;&gt;&gt;]},
</I>&gt;<i>                              {&lt;&lt;&quot;.css&quot;&gt;&gt;, [&lt;&lt;&quot;text/css&quot;&gt;&gt;]},
</I>&gt;<i>                              {&lt;&lt;&quot;.gif&quot;&gt;&gt;, [&lt;&lt;&quot;image/gif&quot;&gt;&gt;]},
</I>&gt;<i>                              {&lt;&lt;&quot;.png&quot;&gt;&gt;, [&lt;&lt;&quot;image/png&quot;&gt;&gt;]},
</I>&gt;<i>                              {&lt;&lt;&quot;.jpg&quot;&gt;&gt;, [&lt;&lt;&quot;image/jpeg&quot;&gt;&gt;]},
</I>&gt;<i>                              {&lt;&lt;&quot;.html&quot;&gt;&gt;, [&lt;&lt;&quot;text/html&quot;&gt;&gt;]}
</I>&gt;<i>                      ]},
</I>&gt;<i>                      {directory, {priv_dir, my_app, [&lt;&lt;&quot;static&quot;&gt;&gt;]}}
</I>&gt;<i>                  ]}
</I>&gt;<i>          ]}
</I>&gt;<i>      ])
</I>&gt;<i>
</I>&gt;<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>&gt;<i>
</I>&gt;<i> if path /static/v/my_app/index.html than serve index.html from my_app
</I>&gt;<i>
</I>&gt;<i> if path /static/v/other_app/test.js that serve test.js from other_app.
</I>&gt;<i>
</I>&gt;<i> and etc....
</I>&gt;<i>
</I>&gt;<i> Main goal to change: `my_app` from here: {directory, {priv_dir, my_app, [&lt;&lt;&quot;static&quot;&gt;&gt;]} dynamically or write custom static handler.
</I>&gt;<i>
</I>&gt;<i> How to do it correctly with cowboy?
</I>
Why don't you add one rule per application?

-- 
Lo&#239;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>