Skip to content

Router not returning assets that aren't text #28

Description

@califrench

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions