<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">You could use my trie data structure
      with list-of-integers keys (and module/function values) to do a
      lookup with patterns like:<br>
      /live/user/*/*/index.m3u8<br>
      <br>
      If that is what you are looking for.  You would just use
      trie:find_match/2 and then perhaps trie:pattern_parse/2 if you
      wanted the individual dynamic values.  The trie:find_match/2
      function is used within cpg within CloudI to handle request
      routing to processes, for the same purpose.<br>
      <br>
      The code is here <a class="moz-txt-link-freetext" href="https://github.com/okeuday/trie">https://github.com/okeuday/trie</a><br>
      <br>
      On 01/29/2013 12:43 PM, Max Lapshin wrote:<br>
    </div>
    <blockquote
cite="mid:CAMxVRxBNuFnvrLg0iN=w9qS+uTYBszgyCioY6bz07pY0xc47XQ@mail.gmail.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>
                <div>
                  <div>
                    <div>
                      <div>
                        <div>
                          <div>
                            <div>
                              <div>
                                <div>
                                  <div>
                                    <div>
                                      <div>
                                        <div>
                                          <div>
                                            <div>
                                              <div>
                                                <div>
                                                  <div>
                                                    <div>
                                                      <div>Hi.<br>
                                                        <br>
                                                        There is a big
                                                        mess with cowboy
                                                        routes in
                                                        erlyvideo.<br>
                                                        <br>
                                                      </div>
                                                      User can access a
                                                      stream via
                                                      different
                                                      http-based
                                                      protocols. For
                                                      example if stream
                                                      is named mtv, urls
                                                      are:<br>
                                                      <br>
                                                      <br>
                                                    </div>
                                                    /mtv/index.m3u8<br>
                                                  </div>
                                                  /mtv/manifest.f4m<br>
                                                </div>
/mtv/hls/2012/12/23/14/59.ts<br>
                                              </div>
/mtv/index-123456780-3600.ts<br>
                                            </div>
                                            /mtv/mpegts<br>
                                            <br>
                                          </div>
                                          <div>All of them are mapping
                                            to different functions<br>
                                          </div>
                                          <div><br>
                                          </div>
                                          If user is accessing a dynamic
                                          stream, url may be:<br>
                                          <br>
                                        </div>
                                        /live/user/15/somestream/index.m3u8 
                                        - here stream name is
                                        "live/user/15/somestream"<br>
                                        <br>
                                      </div>
                                      So I want to detect handler
                                      according to postfix with dynamic
                                      length and even with some
                                      matching.<br>
                                      <br>
                                    </div>
                                    Currently I do so: I map<br>
                                    <br>
                                  </div>
                                  [<<"mtv">>, '...'],
                                  media_handler<br>
                                </div>
                                [<<"live">>, '...',
                                media_handler<br>
                                and then media_handler tries to guess
                                what route is it via dynamic matching:<br>
                                <br>
                                <br>
                              </div>
                              route(Segments) -><br>
                            </div>
                              case Segments of<br>
                          </div>
                              [<<"index.m3u8">>] -> ..<br>
                        </div>
                            [<<"index-", TimeSpec/binary>>]
                        -> ...<br>
                      </div>
                          [Part|Rest] -><br>
                    </div>
                           route(Rest)<br>
                     <br>
                    <br>
                  </div>
                  I think it is a bad idea and think how to rewirte it
                  because this mechanism makes very difficult to add
                  some other handlers to existing prefix, for example
                  map "/mtv/mpegts" to mpegts_handler.<br>
                </div>
                <br>
              </div>
              <div>Also I have a problem with clashing /mtv/index.m3u8
                and /mtv/index-123456780-3600.ts<br>
              </div>
              <div> that should be routed to different handlers.<br>
              </div>
              <div><br>
                My main idea is to bypass cowboy routing and compile
                dynamically routing file with all possible matches for
                streams with known names and make several clauses for
                dynamic streams:<br>
                <br>
              </div>
              [<<"live">>, Segment1,
              <<"index.m3u8">>] -><br>
            </div>
            [<<"live">>, Segment1, Segment2,
            <<"index.m3u8">>] ->  (and so limit depth of
            such name).<br>
            <br>
          </div>
          <div>So I think that I can pregenerate all possible route
            matches, but it will not help with clashing names =(<br>
          </div>
          <div><br>
            <br>
          </div>
          Maybe such router should be made as a cowboy middleware?<br>
        </div>
        Or I'm missing some cool features inside current router?<br>
        <div>
          <div>
            <div>
              <div>
                <div>
                  <div><br>
                    <br>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>