trailblazer-endpoint 0.0.5 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +21 -0
  3. data/README.md +40 -5
  4. data/lib/trailblazer/endpoint/controller.rb +55 -22
  5. data/lib/trailblazer/endpoint/dsl.rb +2 -0
  6. data/lib/trailblazer/endpoint/options.rb +0 -23
  7. data/lib/trailblazer/endpoint/protocol/cipher.rb +27 -0
  8. data/lib/trailblazer/endpoint/protocol/controller.rb +102 -0
  9. data/lib/trailblazer/endpoint/protocol/find_process_model.rb +15 -0
  10. data/lib/trailblazer/endpoint/protocol.rb +2 -3
  11. data/lib/trailblazer/endpoint/version.rb +1 -1
  12. data/lib/trailblazer/endpoint.rb +45 -25
  13. data/test/docs/controller_test.rb +61 -1
  14. data/test/rails-app/Gemfile +17 -1
  15. data/test/rails-app/Gemfile.lock +134 -83
  16. data/test/rails-app/app/concepts/song/cell/create.rb +4 -0
  17. data/test/rails-app/app/concepts/song/cell/new.rb +4 -0
  18. data/test/rails-app/app/concepts/song/operation/create.rb +5 -1
  19. data/test/rails-app/app/concepts/song/view/create.erb +1 -0
  20. data/test/rails-app/app/concepts/song/view/new.erb +1 -0
  21. data/test/rails-app/app/controllers/api/v1/songs_controller.rb +13 -7
  22. data/test/rails-app/app/controllers/application_controller/api.rb +3 -1
  23. data/test/rails-app/app/controllers/application_controller/web.rb +35 -19
  24. data/test/rails-app/app/controllers/application_controller.rb +3 -1
  25. data/test/rails-app/app/controllers/auth_controller.rb +44 -0
  26. data/test/rails-app/app/controllers/home_controller.rb +5 -0
  27. data/test/rails-app/app/controllers/songs_controller.rb +255 -12
  28. data/test/rails-app/app/models/song.rb +4 -1
  29. data/test/rails-app/app/models/user.rb +3 -1
  30. data/test/rails-app/config/application.rb +1 -1
  31. data/test/rails-app/config/environments/test.rb +2 -0
  32. data/test/rails-app/config/routes.rb +21 -3
  33. data/test/rails-app/test/controllers/api_songs_controller_test.rb +6 -2
  34. data/test/rails-app/test/controllers/songs_controller_test.rb +125 -10
  35. data/trailblazer-endpoint.gemspec +2 -2
  36. metadata +23 -9
@@ -1,81 +1,123 @@
1
+ PATH
2
+ remote: ../../../trailblazer-activity-dsl-linear
3
+ specs:
4
+ trailblazer-activity-dsl-linear (0.4.3)
5
+ trailblazer-activity (>= 0.12.2, < 1.0.0)
6
+
7
+ PATH
8
+ remote: ../../../trailblazer-activity
9
+ specs:
10
+ trailblazer-activity (0.13.0)
11
+ trailblazer-context (~> 0.5.0)
12
+ trailblazer-option (~> 0.1.0)
13
+
14
+ PATH
15
+ remote: ../../../trailblazer-context
16
+ specs:
17
+ trailblazer-context (0.5.0)
18
+ hashie (>= 3.0.0)
19
+
20
+ PATH
21
+ remote: ../../../trailblazer-operation
22
+ specs:
23
+ trailblazer-operation (0.7.5)
24
+ trailblazer-activity (>= 0.12.2, < 1.0.0)
25
+ trailblazer-activity-dsl-linear (>= 0.4.1, < 1.0.0)
26
+ trailblazer-developer (>= 0.0.21, < 1.0.0)
27
+
1
28
  PATH
2
29
  remote: ../..
3
30
  specs:
4
- trailblazer-endpoint (0.0.4)
5
- trailblazer-activity-dsl-linear (>= 0.3.0, < 0.4.0)
31
+ trailblazer-endpoint (0.0.9)
32
+ trailblazer-activity-dsl-linear (>= 0.4.0, < 0.5.0)
6
33
 
7
34
  GEM
8
35
  remote: https://rubygems.org/
9
36
  specs:
10
- actioncable (6.0.3.2)
11
- actionpack (= 6.0.3.2)
37
+ actioncable (6.0.3.4)
38
+ actionpack (= 6.0.3.4)
12
39
  nio4r (~> 2.0)
13
40
  websocket-driver (>= 0.6.1)
14
- actionmailbox (6.0.3.2)
15
- actionpack (= 6.0.3.2)
16
- activejob (= 6.0.3.2)
17
- activerecord (= 6.0.3.2)
18
- activestorage (= 6.0.3.2)
19
- activesupport (= 6.0.3.2)
41
+ actionmailbox (6.0.3.4)
42
+ actionpack (= 6.0.3.4)
43
+ activejob (= 6.0.3.4)
44
+ activerecord (= 6.0.3.4)
45
+ activestorage (= 6.0.3.4)
46
+ activesupport (= 6.0.3.4)
20
47
  mail (>= 2.7.1)
21
- actionmailer (6.0.3.2)
22
- actionpack (= 6.0.3.2)
23
- actionview (= 6.0.3.2)
24
- activejob (= 6.0.3.2)
48
+ actionmailer (6.0.3.4)
49
+ actionpack (= 6.0.3.4)
50
+ actionview (= 6.0.3.4)
51
+ activejob (= 6.0.3.4)
25
52
  mail (~> 2.5, >= 2.5.4)
26
53
  rails-dom-testing (~> 2.0)
27
- actionpack (6.0.3.2)
28
- actionview (= 6.0.3.2)
29
- activesupport (= 6.0.3.2)
54
+ actionpack (6.0.3.4)
55
+ actionview (= 6.0.3.4)
56
+ activesupport (= 6.0.3.4)
30
57
  rack (~> 2.0, >= 2.0.8)
31
58
  rack-test (>= 0.6.3)
32
59
  rails-dom-testing (~> 2.0)
33
60
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
- actiontext (6.0.3.2)
35
- actionpack (= 6.0.3.2)
36
- activerecord (= 6.0.3.2)
37
- activestorage (= 6.0.3.2)
38
- activesupport (= 6.0.3.2)
61
+ actiontext (6.0.3.4)
62
+ actionpack (= 6.0.3.4)
63
+ activerecord (= 6.0.3.4)
64
+ activestorage (= 6.0.3.4)
65
+ activesupport (= 6.0.3.4)
39
66
  nokogiri (>= 1.8.5)
40
- actionview (6.0.3.2)
41
- activesupport (= 6.0.3.2)
67
+ actionview (6.0.3.4)
68
+ activesupport (= 6.0.3.4)
42
69
  builder (~> 3.1)
43
70
  erubi (~> 1.4)
44
71
  rails-dom-testing (~> 2.0)
45
72
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
- activejob (6.0.3.2)
47
- activesupport (= 6.0.3.2)
73
+ activejob (6.0.3.4)
74
+ activesupport (= 6.0.3.4)
48
75
  globalid (>= 0.3.6)
49
- activemodel (6.0.3.2)
50
- activesupport (= 6.0.3.2)
51
- activerecord (6.0.3.2)
52
- activemodel (= 6.0.3.2)
53
- activesupport (= 6.0.3.2)
54
- activestorage (6.0.3.2)
55
- actionpack (= 6.0.3.2)
56
- activejob (= 6.0.3.2)
57
- activerecord (= 6.0.3.2)
76
+ activemodel (6.0.3.4)
77
+ activesupport (= 6.0.3.4)
78
+ activerecord (6.0.3.4)
79
+ activemodel (= 6.0.3.4)
80
+ activesupport (= 6.0.3.4)
81
+ activestorage (6.0.3.4)
82
+ actionpack (= 6.0.3.4)
83
+ activejob (= 6.0.3.4)
84
+ activerecord (= 6.0.3.4)
58
85
  marcel (~> 0.3.1)
59
- activesupport (6.0.3.2)
86
+ activesupport (6.0.3.4)
60
87
  concurrent-ruby (~> 1.0, >= 1.0.2)
61
88
  i18n (>= 0.7, < 2)
62
89
  minitest (~> 5.1)
63
90
  tzinfo (~> 1.1)
64
91
  zeitwerk (~> 2.2, >= 2.2.2)
65
92
  builder (3.2.4)
93
+ cells (4.1.7)
94
+ declarative-builder (< 0.2.0)
95
+ declarative-option (< 0.2.0)
96
+ tilt (>= 1.4, < 3)
97
+ uber (< 0.2.0)
98
+ cells-erb (0.1.0)
99
+ cells (~> 4.0)
100
+ erbse (>= 0.1.1)
101
+ cells-rails (0.1.3)
102
+ actionpack (>= 5.0)
103
+ cells (>= 4.1.6, < 5.0.0)
66
104
  concurrent-ruby (1.1.7)
67
105
  crass (1.0.6)
68
106
  declarative (0.0.20)
107
+ declarative-builder (0.1.0)
108
+ declarative-option (< 0.2.0)
69
109
  declarative-option (0.1.0)
70
- erubi (1.9.0)
110
+ erbse (0.1.4)
111
+ temple
112
+ erubi (1.10.0)
71
113
  globalid (0.4.2)
72
114
  activesupport (>= 4.2.0)
73
- hashie (4.1.0)
115
+ hashie (5.0.0)
74
116
  hirb (0.7.3)
75
- i18n (1.8.5)
117
+ i18n (1.8.7)
76
118
  concurrent-ruby (~> 1.0)
77
119
  jwt (2.2.2)
78
- loofah (2.7.0)
120
+ loofah (2.8.0)
79
121
  crass (~> 1.0.2)
80
122
  nokogiri (>= 1.5.9)
81
123
  mail (2.7.1)
@@ -85,89 +127,98 @@ GEM
85
127
  method_source (1.0.0)
86
128
  mimemagic (0.3.5)
87
129
  mini_mime (1.0.2)
88
- mini_portile2 (2.4.0)
89
- minitest (5.14.2)
130
+ mini_portile2 (2.5.0)
131
+ minitest (5.14.3)
132
+ minitest-line (0.6.5)
133
+ minitest (~> 5.0)
90
134
  multi_json (1.15.0)
91
- nio4r (2.5.2)
92
- nokogiri (1.10.10)
93
- mini_portile2 (~> 2.4.0)
135
+ nio4r (2.5.4)
136
+ nokogiri (1.11.1)
137
+ mini_portile2 (~> 2.5.0)
138
+ racc (~> 1.4)
139
+ nokogiri (1.11.1-x86_64-linux)
140
+ racc (~> 1.4)
141
+ racc (1.5.2)
94
142
  rack (2.2.3)
95
143
  rack-test (1.1.0)
96
144
  rack (>= 1.0, < 3)
97
- rails (6.0.3.2)
98
- actioncable (= 6.0.3.2)
99
- actionmailbox (= 6.0.3.2)
100
- actionmailer (= 6.0.3.2)
101
- actionpack (= 6.0.3.2)
102
- actiontext (= 6.0.3.2)
103
- actionview (= 6.0.3.2)
104
- activejob (= 6.0.3.2)
105
- activemodel (= 6.0.3.2)
106
- activerecord (= 6.0.3.2)
107
- activestorage (= 6.0.3.2)
108
- activesupport (= 6.0.3.2)
145
+ rails (6.0.3.4)
146
+ actioncable (= 6.0.3.4)
147
+ actionmailbox (= 6.0.3.4)
148
+ actionmailer (= 6.0.3.4)
149
+ actionpack (= 6.0.3.4)
150
+ actiontext (= 6.0.3.4)
151
+ actionview (= 6.0.3.4)
152
+ activejob (= 6.0.3.4)
153
+ activemodel (= 6.0.3.4)
154
+ activerecord (= 6.0.3.4)
155
+ activestorage (= 6.0.3.4)
156
+ activesupport (= 6.0.3.4)
109
157
  bundler (>= 1.3.0)
110
- railties (= 6.0.3.2)
158
+ railties (= 6.0.3.4)
111
159
  sprockets-rails (>= 2.0.0)
112
160
  rails-dom-testing (2.0.3)
113
161
  activesupport (>= 4.2.0)
114
162
  nokogiri (>= 1.6)
115
163
  rails-html-sanitizer (1.3.0)
116
164
  loofah (~> 2.3)
117
- railties (6.0.3.2)
118
- actionpack (= 6.0.3.2)
119
- activesupport (= 6.0.3.2)
165
+ railties (6.0.3.4)
166
+ actionpack (= 6.0.3.4)
167
+ activesupport (= 6.0.3.4)
120
168
  method_source
121
169
  rake (>= 0.8.7)
122
170
  thor (>= 0.20.3, < 2.0)
123
- rake (13.0.1)
124
- representable (3.0.4)
171
+ rake (13.0.3)
172
+ representable (3.1.1)
125
173
  declarative (< 0.1.0)
126
- declarative-option (< 0.2.0)
174
+ trailblazer-option (>= 0.1.1, < 0.2.0)
127
175
  uber (< 0.2.0)
128
176
  sprockets (4.0.2)
129
177
  concurrent-ruby (~> 1.0)
130
178
  rack (> 1, < 3)
131
- sprockets-rails (3.2.1)
179
+ sprockets-rails (3.2.2)
132
180
  actionpack (>= 4.0)
133
181
  activesupport (>= 4.0)
134
182
  sprockets (>= 3.0.0)
135
183
  sqlite3 (1.4.2)
184
+ temple (0.8.2)
136
185
  thor (1.0.1)
137
186
  thread_safe (0.3.6)
138
- trailblazer-activity (0.11.3)
139
- trailblazer-context (>= 0.3.1, < 0.4.0)
140
- trailblazer-activity-dsl-linear (0.3.2)
141
- trailblazer-activity (>= 0.11.2, < 1.0.0)
142
- trailblazer-context (0.3.1)
143
- hashie (~> 4.1)
144
- trailblazer-developer (0.0.16)
187
+ tilt (2.0.10)
188
+ trailblazer-cells (0.0.3)
189
+ cells (>= 4.1.0.rc1, < 5.0.0)
190
+ trailblazer-developer (0.0.22)
145
191
  hirb
146
- representable
147
- trailblazer-activity (>= 0.11.0, < 1.0.0)
148
- trailblazer-activity-dsl-linear
149
- trailblazer-operation (0.6.5)
150
- trailblazer-activity (>= 0.11.2, < 1.0.0)
151
- trailblazer-activity-dsl-linear (>= 0.3.2, < 1.0.0)
152
- trailblazer-developer (>= 0.0.8)
153
- tzinfo (1.2.7)
192
+ representable (>= 3.1.1, < 4.0.0)
193
+ trailblazer-activity (>= 0.12.2, < 1.0.0)
194
+ trailblazer-activity-dsl-linear (>= 0.4.1, < 1.0.0)
195
+ trailblazer-option (0.1.2)
196
+ tzinfo (1.2.9)
154
197
  thread_safe (~> 0.1)
155
198
  uber (0.1.0)
156
199
  websocket-driver (0.7.3)
157
200
  websocket-extensions (>= 0.1.0)
158
201
  websocket-extensions (0.1.5)
159
- zeitwerk (2.4.0)
202
+ zeitwerk (2.4.2)
160
203
 
161
204
  PLATFORMS
162
205
  ruby
206
+ x86_64-linux
163
207
 
164
208
  DEPENDENCIES
209
+ cells-erb
210
+ cells-rails
165
211
  jwt
212
+ minitest-line
166
213
  multi_json
167
214
  rails (~> 6.0.3, >= 6.0.3.1)
168
215
  sqlite3 (~> 1.4)
216
+ trailblazer-activity!
217
+ trailblazer-activity-dsl-linear!
218
+ trailblazer-cells
219
+ trailblazer-context!
169
220
  trailblazer-endpoint!
170
- trailblazer-operation
221
+ trailblazer-operation!
171
222
 
172
223
  BUNDLED WITH
173
- 2.1.4
224
+ 2.2.11
@@ -0,0 +1,4 @@
1
+ module Song::Cell
2
+ class Create < Trailblazer::Cell
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Song::Cell
2
+ class New < Trailblazer::Cell
3
+ end
4
+ end
@@ -1,6 +1,6 @@
1
1
  module Song::Operation
2
2
  class Create < Trailblazer::Operation
3
- # include Trailblazer::Activity::Testing.def_steps(:model, :validate, :save)
3
+ step :contract
4
4
  step :model
5
5
  # step :validate
6
6
  # step :save
@@ -9,5 +9,9 @@ module Song::Operation
9
9
  return unless params[:id]
10
10
  ctx[:model] = Song.new(params[:id])
11
11
  end
12
+
13
+ def contract(ctx, **)
14
+ ctx[:contract] = Struct.new(:errors).new()
15
+ end
12
16
  end
13
17
  end
@@ -0,0 +1 @@
1
+ <div><%= model %><%= options[:current_user] %></div>
@@ -0,0 +1 @@
1
+ <div><%= model %></div>
@@ -1,34 +1,40 @@
1
1
  #:controller
2
2
  module Api
3
3
  module V1
4
+ #:endpoint
4
5
  class SongsController < ApplicationController::Api
5
- endpoint Song::Operation::Create.to_s, domain_activity: Song::Operation::Create
6
- endpoint Song::Operation::Show.to_s, domain_activity: Song::Operation::Show do {Output(:not_found) => Track(:not_found)} end
6
+ endpoint Song::Operation::Create
7
+ endpoint Song::Operation::Show do
8
+ {Output(:not_found) => Track(:not_found)} # add additional wiring to {domain_activity}
9
+ end
10
+ #:endpoint end
7
11
 
8
12
  #:create
9
13
  def create
10
- endpoint Song::Operation::Create.to_s, representer_class: Song::Representer
14
+ endpoint Song::Operation::Create, representer_class: Song::Representer
11
15
  end
12
16
  #:create end
13
17
 
18
+ #~empty
14
19
  def show
15
- endpoint Song::Operation::Show.to_s, representer_class: Song::Representer
20
+ endpoint Song::Operation::Show, representer_class: Song::Representer
16
21
  end
17
22
 
18
23
  def show_with_options
19
- endpoint Song::Operation::Show.to_s, representer_class: Song::Representer, protocol_failure_block: ->(ctx, endpoint_ctx:, **) { head endpoint_ctx[:status] + 1 }
24
+ endpoint Song::Operation::Show, representer_class: Song::Representer, protocol_failure_block: ->(ctx, endpoint_ctx:, **) { head endpoint_ctx[:status] + 1 }
20
25
  end
21
26
 
22
27
  class WithOptionsController < ApplicationController::Api
23
- endpoint Song::Operation::Show.to_s, domain_activity: Song::Operation::Show do {Output(:not_found) => Track(:not_found)} end
28
+ endpoint Song::Operation::Show do {Output(:not_found) => Track(:not_found)} end
24
29
 
25
30
  #:show-options
26
31
  def show
27
- endpoint Song::Operation::Show.to_s, representer_class: Song::Representer,
32
+ endpoint Song::Operation::Show, representer_class: Song::Representer,
28
33
  protocol_failure_block: ->(ctx, endpoint_ctx:, **) { head endpoint_ctx[:status] + 1 }
29
34
  end
30
35
  #:show-options end
31
36
  end
37
+ #~empty end
32
38
  end
33
39
  end
34
40
  end
@@ -1,6 +1,8 @@
1
1
  #:app-controller
2
+ #:app-include
2
3
  class ApplicationController::Api < ApplicationController
3
- include Trailblazer::Endpoint::Controller.module(api: true)
4
+ include Trailblazer::Endpoint::Controller.module(api: true, application_controller: true)
5
+ #:app-include end
4
6
 
5
7
  def self.options_for_block_options(ctx, controller:, **)
6
8
  response_block = ->(ctx, endpoint_ctx:, **) do
@@ -1,30 +1,46 @@
1
+ #:app-include
2
+ #:options
3
+ #:protocol
4
+ #:generic
1
5
  class ApplicationController::Web < ApplicationController
2
- extend Trailblazer::Endpoint::Controller
3
- include Trailblazer::Endpoint::Controller::InstanceMethods::DSL
4
- include Trailblazer::Endpoint::Controller::Rails
5
- extend Trailblazer::Endpoint::Controller::Rails::DefaultBlocks
6
- extend Trailblazer::Endpoint::Controller::Rails::DefaultParams
7
- include Trailblazer::Endpoint::Controller::Rails::Process
6
+ #~pskip
7
+ #~gskip
8
+ include Trailblazer::Endpoint::Controller.module(dsl: true, application_controller: true)
9
+ #:app-include end
8
10
 
9
- # directive :options_for_endpoint, method(:options_for_endpoint), method(:request_options)
10
- # directive :options_for_flow_options, method(:options_for_flow_options)
11
- # directive :options_for_block_options, method(:options_for_block_options)
11
+ def self.options_for_endpoint(ctx, controller:, **)
12
+ {
13
+ session: controller.session,
14
+ }
15
+ end
12
16
 
13
- Protocol = Class.new(Trailblazer::Endpoint::Protocol) do
14
- # no {:seq} dependency
15
- def authenticate(ctx, domain_ctx:, **)
16
- # puts domain_ctx[:params].inspect
17
+ directive :options_for_endpoint, method(:options_for_endpoint)
18
+ #:options end
17
19
 
18
- puts "TODO: should we always inject params into the endpoint_ctx?"
19
- domain_ctx[:params][:authenticate] == "false" ? false : true
20
+ # directive :options_for_flow_options, method(:options_for_flow_options)
21
+ # directive :options_for_block_options, method(:options_for_block_options)
22
+ #~pskip end
23
+ class Protocol < Trailblazer::Endpoint::Protocol
24
+ # provide method for {step :authenticate}
25
+ def authenticate(ctx, session:, **)
26
+ ctx[:current_user] = User.find_by(id: session[:user_id])
20
27
  end
21
28
 
29
+ # provide method for {step :policy}
22
30
  def policy(ctx, domain_ctx:, **)
23
- domain_ctx[:params][:policy] == "false" ? false : true
31
+ Policy.(domain_ctx)
24
32
  end
25
- end
26
33
 
27
- endpoint protocol: Protocol, adapter: Trailblazer::Endpoint::Adapter::Web do
28
- {Output(:not_found) => Track(:not_found)}
34
+ Trailblazer::Endpoint::Protocol::Controller.insert_copy_to_domain_ctx!(self, {:current_user => :current_user})
35
+ Trailblazer::Endpoint::Protocol::Controller.insert_copy_from_domain_ctx!(self, {:model => :process_model})
29
36
  end
37
+ #:protocol end
38
+ Policy = ->(domain_ctx) { domain_ctx[:params][:policy] == "false" ? false : true }
39
+ #~gskip end
40
+ endpoint protocol: Protocol, adapter: Trailblazer::Endpoint::Adapter::Web
30
41
  end
42
+ #:generic end
43
+
44
+ # do
45
+ # {Output(:not_found) => Track(:not_found)}
46
+ # end
@@ -1,7 +1,9 @@
1
1
  require "trailblazer/endpoint/controller"
2
2
 
3
3
  class ApplicationController < ActionController::Base
4
-
4
+ def self.current_user_in_domain_ctx
5
+ ->(_ctx, ((ctx, a), b)) { ctx[:domain_ctx][:current_user] = ctx[:current_user]; [_ctx, [[ctx, a], b]] } # FIXME: extract to lib?
6
+ end
5
7
  end
6
8
 
7
9
 
@@ -0,0 +1,44 @@
1
+ class AuthController < ApplicationController::Web
2
+ # We could use a fully-fledged operation here, with a contract and whatnot.
3
+ def self.authenticate(ctx, request:, params:, **)
4
+ if params[:username] == "yogi@trb.to" && params[:password] == "secret"
5
+ ctx[:current_user] = User.find_by(email: params[:username])
6
+
7
+ return true
8
+ else
9
+ return false # let's be extra explicit!
10
+ end
11
+ end
12
+
13
+ endpoint("sign_in", domain_activity: Class.new(Trailblazer::Activity::Railway)) do
14
+ # step nil, delete: :domain_activity
15
+ step nil, delete: :policy
16
+ step AuthController.method(:authenticate), replace: :authenticate, inherit: true, id: :authenticate
17
+
18
+ {}
19
+ end
20
+
21
+ def self.options_for_endpoint(ctx, controller:, **)
22
+ {
23
+ params: controller.params,
24
+ request: controller.request,
25
+ }
26
+ end
27
+
28
+ directive :options_for_endpoint, method(:options_for_endpoint)
29
+
30
+ def sign_in
31
+ endpoint "sign_in" do |ctx, current_user:, **|
32
+ session[:user_id] = current_user.id # Working on {session} is HTTP-specific and done in the controller.
33
+
34
+ redirect_to dashboard_path
35
+ # render html: "Yes!"
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def dashboard_path
42
+ "/"
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ class HomeController < ApplicationController
2
+ def dashboard
3
+ render html: "Yo!"
4
+ end
5
+ end