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
{{ message }}
Repository navigation
Commit a7264ff
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
3
3
### 2.2.2 (Next)
4
4
5
+
* Add a configurable API application and separately mountable team read/registration endpoints, preserving the default API while supporting custom routes and registration-only applications - [@dblock](https://github.com/dblock), [@Copilot](https://github.com/apps/copilot-swe-agent).
@@ -151,6 +153,58 @@ Navigate to either [localhost:9292](http://localhost:9292) or the ngrok URL abov
151
153
152
154
This library implements an app, [SlackRubyBotServer::App](lib/slack-ruby-bot-server/app.rb) and a service manager, [SlackRubyBotServer::Service](lib/slack-ruby-bot-server/service.rb). It also provides [default HTML templates and JS scripts](public) for Slack integration.
153
155
156
+
#### Custom Endpoints
157
+
158
+
Set `config.api` to a Rack application, typically a `Grape::API` class, to customize the API without reopening the framework's classes. The default is `nil`, which uses `SlackRubyBotServer::Api::Endpoints::RootEndpoint`, including extensions mounted there by other gems. `SlackRubyBotServer::Config.reset!` restores this default.
159
+
160
+
To add an endpoint alongside the default API:
161
+
162
+
```ruby
163
+
classExtraApi < Grape::API
164
+
prefix 'api'
165
+
format:json
166
+
167
+
get :foobardo
168
+
{ ok:true }
169
+
end
170
+
end
171
+
172
+
classApplicationApi < Grape::API
173
+
mount SlackRubyBotServer::Api::Endpoints::RootEndpoint
174
+
mount ExtraApi
175
+
end
176
+
177
+
SlackRubyBotServer.configure do |config|
178
+
config.api =ApplicationApi
179
+
end
180
+
```
181
+
182
+
Configure this before starting the application. In `config.ru`, continue running `SlackRubyBotServer::Api::Middleware.instance`; both `/api/foobar` and the existing `/api` routes then share the framework's CORS, URL-rewrite, and page middleware. A separate `Rack::Cascade` stack is unnecessary.
183
+
184
+
In Rails, require the file defining `ApplicationApi` from your initializer before assigning `config.api`. For reloadable classes, make the assignment inside `Rails.application.config.to_prepare` so it references the current class. Mount `SlackRubyBotServer::Api::Middleware.instance` in your routes, for example `mount SlackRubyBotServer::Api::Middleware.instance => '/'`, rather than bypassing that middleware stack.
185
+
186
+
#### Team Endpoint Visibility
187
+
188
+
The default API exposes `GET /api/teams` and `GET /api/teams/:id` publicly. To retain OAuth registration without those read endpoints, use the separately mountable `TeamsEndpoint::Create`. `TeamsEndpoint::Read` contains the list and detail routes; `TeamsEndpoint` continues to mount both for backward compatibility.
mount SlackRubyBotServer::Api::Endpoints::TeamsEndpoint::Create
199
+
end
200
+
201
+
SlackRubyBotServer.configure do |config|
202
+
config.api =RegistrationApi
203
+
end
204
+
```
205
+
206
+
This replaces the default root API: it does not expose its status, root discovery, Swagger, or team-read routes. Do not also mount `RootEndpoint` or `TeamsEndpoint`, since either would restore the public team reads. If you use the Events extension or other custom endpoints, explicitly mount their routes with their required signature verification too. Add your own authentication before mounting `TeamsEndpoint::Read` if you need protected team queries. OAuth registration still requires a valid Slack authorization code; this configuration does not add a general authentication layer.
207
+
154
208
#### App
155
209
156
210
The app instance checks for a working database connection, ensures indexes, performs migrations, sets up bot aliases and log levels. You can introduce custom behavior into the app lifecycle by subclassing `SlackRubyBotServer::App` and creating an instance of the child class in `config.ru`.
0 commit comments