Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router not returning assets that aren't text #28

Open
califrench opened this issue Mar 10, 2016 · 1 comment
Open

Router not returning assets that aren't text #28

califrench opened this issue Mar 10, 2016 · 1 comment

Comments

@califrench
Copy link
Contributor

This is kind of the same as #25 but that issue encompassed two issues:

  1. All static files were returned in a response with a "text/plain" mimeType -> Now fixed
  2. Media assets can't be returned because the following line failed
// Router.swift:111
...
if let body = String(data:contents!, encoding: NSUTF8StringEncoding) {
...

Any file that is a jpeg or png etc... Returns a nil body on this line which leads to this code returning a notFound Response:

// Router.swift:95
if let staticFile = serveStaticFile(newRequest) {
    return staticFile as! Response
}

return notFound(newRequest) as! Response

So we are still having an issue with not returning media assets this isn't in line with the README

Static assets (JavaScript, CSS, images etc.) are loaded from Public directory by default
This is crucial and needs to be fixed before Swifton can be useful. I can't imagine a website without any media assets!

I'm willing to investigate this much further but we may need to modify the router to return ResponseTypes from the router instead of Inquiline Response types... Of course any other thoughts are welcome!

sauliusgrigaitis added a commit that referenced this issue Mar 16, 2016
@califrench
Copy link
Contributor Author

Looks like release 0.3.2 of Inquiline changed the way Responses work and now support PayloadConvertible objects instead of plain strings for the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant