小编Fed*_*ria的帖子

authenticate_or_request_with_http_token返回html而不是json

我已经创建了一个rails-api应用程序并继续使用令牌认证来保护它.

我设置了一个before_filter调用使用的方法authenticate_or_request_with_http_token.一切正常,但是,当身份验证不正确时,我得到一个HTML响应.

如何定义响应的格式?

before_filter :restrict_access

private

def restrict_access
  authenticate_or_request_with_http_token do |token, options|
    check_token token
  end
end

def check_token(token)
  Session.exists?(access_token: token)
end
Run Code Online (Sandbox Code Playgroud)

json ruby-on-rails rails-api

16
推荐指数
1
解决办法
2917
查看次数

使用Yo生成的Angular项目中的跳过测试

我正在做一个小玩具项目来测试Yeoman和棱角分明.

创建应用程序后,yo angular我开始编写服务及其测试.在我试图忽略测试之前,一切都很完美.

从我读过,我应该能够忽略测试改变itxit和适应变化describexdescribe.

但是,当我保存和咕噜启动测试,我得到一个'xit' is not defined'xdescribe' is not defined错误.

有什么我想念的吗?

jasmine angularjs yeoman-generator

6
推荐指数
1
解决办法
2831
查看次数

在模拟服务 URL 中使用通配符

我需要模拟一个休息服务,该模拟已经在 SoapUI 上运行了。问题是我创建了一个带有这样的 URL 的模拟/test/userA/

有没有办法创建一个也能响应 url 的模拟/test/userB/?我在想类似/test/user?/或 的东西test/user[A-Z]/。用 SoapUI 可以吗?

rest groovy mocking soapui

5
推荐指数
1
解决办法
3976
查看次数