You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+64-3Lines changed: 64 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# ChatopsControllers
2
2
3
-
Rails helpers for JSON-RPC based easy chatops.
3
+
Rails helpers for easy, JSON-RPC based chatops.
4
4
5
5
A minimal controller example:
6
6
@@ -22,7 +22,7 @@ Some routing boilerplate is required in `config/routes.rb`:
22
22
23
23
```ruby
24
24
Rails.application.routes.draw do
25
-
post "/_chatops/:action", controller:"chatops"
25
+
post "/_chatops/:chatop", controller:"anonymous", action::execute_chatop
26
26
get "/_chatops" => "chatops#list"
27
27
end
28
28
```
@@ -80,7 +80,7 @@ have an input validation or other handle-able error, you can use
80
80
`jsonrpc_failure` to send a helpful error message.
81
81
82
82
ChatOps are regular old rails controller actions, and you can use niceties like
83
-
`before_filter` and friends. `before_filter :echo, :load_user` for the above
83
+
`before_action` and friends. `before_action :echo, :load_user` for the above
84
84
case would call `load_user` before running `echo`.
85
85
86
86
## Authentication
@@ -105,3 +105,64 @@ foo` and `.echo foo in staging` to use two different servers to run `.echo foo`.
105
105
script/bootstrap
106
106
script/test
107
107
```
108
+
109
+
## Upgrading from early versions
110
+
111
+
Early versions of RPC chatops had two major changes:
112
+
113
+
##### They used Rails' dynamic `:action` routing, which was deprecated in Rails 5.
114
+
115
+
To work around this, you need to update your router boilerplate:
116
+
117
+
This:
118
+
119
+
```ruby
120
+
post "/_chatops/:action", controller:"anonymous"
121
+
```
122
+
123
+
Becomes this:
124
+
125
+
```ruby
126
+
post "/_chatops/:chatop", controller:"anonymous", action::execute_chatop
127
+
```
128
+
129
+
#####
130
+
131
+
They did not require a prefix. Version 2 of the Chatops RPC protocol assumes a unique prefix for each endpoint. This decision was made for several reasons:
132
+
133
+
* The previous suffix-based system creates semantic ambiguities with keyword arguments
134
+
* Prefixes allow big improvements to `.help`
135
+
* Prefixes make regex-clobbering impossible
136
+
137
+
To upgrade to version 2, upgrade to version 2.x of this gem. To migrate:
138
+
139
+
* Migrate your chatops to remove any prefixes you have:
0 commit comments