Skip to content
Myr

refactored `req.flash()`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent a4621a6 · Browse files · 1 file+10 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−4 removed

  • other:+10 added−4 removed

1 file+10 added−4 removed

modified:lib/request.js+10 added-4 removed
223 unmodified lines
224225req.flash = function(type, msg){226 if (this.session === undefined) throw Error('req.flash() requires sessions');227 var msgs = this.session.flash = this.session.flash || {};228229 // notification230 if (type && msg) {231 var i = 2232 , args = arguments233 , formatters = this.app.formatters || {};
3 unmodified lines
237 var formatter = formatters[format];238 if (formatter) return formatter(args[i++]);239 });240 return (msgs[type] = msgs[type] || []).push(msg);241 }242243 // flush messages for a specific type239 } else if (type) {244 if (type) {245 var arr = msgs[type];246 delete msgs[type];247 return arr || [];243 } else {244 this.session.flash = {};245 return msgs;248 }249250 // flush all messages251 this.session.flash = {};252 return msgs;253};254255/**256 * Check if the incoming request contains the "Content-Type"
72 unmodified lines