Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://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 irc.perl.org 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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-26 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found