codecamp

Sinatra 挂起

要想直接地停止请求 (不处理请求),在过滤器或者路由中使用:

halt

你也可以指定挂起时的状态码:

halt 410

或者消息体:

halt 'this will be the body'

或者两者;

halt 401, 'go away!'

也可以带消息头:

halt 402, {'Content-Type' => 'text/plain'}, 'revenge'


Sinatra 使用 Sessions
Sinatra 让路
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Sinatra 配置

Sinatra 错误处理

Sinatra Sinatra::Base - 中间件,程序库和模块化应用

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }