2016-08-22 118 views
0

我有一個golang程序每秒(作爲一個帖子)發送一個項目到服務器。一個Golang收聽節目時輸出項目作爲哈希:GOLang發佈到Rails應用程序

{"Address":"[email protected]", "EmailType":"test", "Event":"test", "Timestamp":1234}. 

現在我想這個數據發送到軌道服務器和每個事件保存到數據庫中。然而,當我點程序到我的路線後我得到這個錯誤:

Started POST "/items" for ::1 at 2016-08-23 00:36:17 +0200 

Processing by ItemsController#create as HTML 

Can't verify CSRF token authenticity 

Completed 422 Unprocessable Entity in 1ms (ActiveRecord: 0.0ms) 

的錯誤是坐上golang程序:

Sending events to: http://localhost:4000/items 
2016/08/23 00:36:17 Expecting 200 returned, got %!f(int=422) 

任何人可以幫助我什麼問題呢?

回答

1

您需要爲ItemsController#create操作禁用CSRF驗證。您的ItemsController

skip_before_action :verify_authenticity_token, only: [:create] 
+0

真棒工作! – Gregor