-
Notifications
You must be signed in to change notification settings - Fork 46
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
Suggestion - self.file alongside self.template that serves a single static file to a given URL. #144
Comments
IMHO this should automatically set the content-type as well. |
I'd suggest adding an optional MIME-type variable on the call. Testing a file's magic can be unreliable and slow. Think for example of a 1MB UTF-8 with the only non-ASCII character being a copyright symbol at the end. This way the user can either override bad magic detection or set it for performance purposes. |
I'd say by default it should use the same algorithm as the static file serving, (is that based on extension?) but the user can override it with an optional parameter as @drforr suggests. |
This makes sense :) |
Right. I wasn't suggesting avoiding the MIME-type check altogether, I was just suggesting a way to override the behavior. Usually checking magic is fast so it's not a problem, but I've worked with documents where it's unreliable, or sometimes you simply want to, say, upgrade text/ASCII to text/UTF-8 because it's the right thing to do. |
This adds the routine and method 'file', which serves the purpose of simply serving a file as-is. The content-type can optionally be specified, but is not checked, defaults to text/plain;utf8
This adds the routine and method 'file', which serves the purpose of simply serving a file as-is. The content-type can optionally be specified, but is not checked, defaults to text/plain;utf8
This adds the routine and method 'file', which serves the purpose of simply serving a file as-is. The content-type can optionally be specified, but is not checked, defaults to text/plain;utf8
This adds the routine and method 'render-file', which serves the purpose of simply serving a file. The content-type can optionally be specified, otherwise render() will set it.
This adds the routine and method 'render-file', which serves the purpose of simply serving a file. The content-type can optionally be specified, otherwise render() will set it.
This adds the routine and method 'render-file', which serves the purpose of simply serving a file. The content-type can optionally be specified, otherwise render() will set it.
This adds the routine and method 'render-file', which serves the purpose of simply serving a file. The content-type can optionally be specified, otherwise render() will set it.
This adds the routine and method 'render-file', which serves the purpose of simply serving a file. The content-type can optionally be specified, otherwise render() will set it.
It's really a synonym for self.template, it just explicitly doesn't do any preprocessing to the text. No real speed improvements, just clarity, being able to say that route X is completely static, no preprocessing.
--- cut here ---$rootdir = $ ?FILE.IO.parent.parent;
submethod BUILD(|) {
my
self.get: '/' => sub {
self.file: 'index.html'; # <--- There.
};
}
--- cut here ---
The text was updated successfully, but these errors were encountered: