Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Regarding "the best way" of serving Javascript files, you should just put them in the /public directory and remove your /javascripts route. Any request that does not match a route, e.g. GET /foo/bar.js will look into /public for a file called /public/foo/bar.js and serve that directly; if it doesn't exist you get a 404 as expected. In your case you're not using system_path in your call to send_file, so the file will only be served from the public directory anyway...

I've looked at the source for send_file and it does seem to propagate the MIME type from the function call to the rendering of the response. However, I've been bitten by Dancer::Test before. Since it's returning a filehandle instead of a rendered response I'd say it's not calling get_file_response_for_path from Dancer::Renderer, which is responsible for adding the Content-Type header. In short, don't expect Dancer::Test to mimic a real web app from end to end. It's there to allow you to test plugins and such. Regarding response_exists, that does seem like a documentation bug.

Finally, rest assured that Dancer *is* a mature framework. We use it at $work for many internal applications and we have never had serious problems.

The Dancer folk at #dancer on are very responsive and friendly, be sure to check there if you have other questions.

In reply to Re: Dancer bugs? send_file(), content type, and response_content_is() by pokki
in thread Dancer bugs? send_file(), content type, and response_content_is() by hardburn

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (5)
    As of 2017-11-23 05:52 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (328 votes). Check out past polls.