gloo 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/gloo.gemspec +8 -3
  4. data/lib/VERSION +1 -1
  5. data/lib/VERSION_NOTES +7 -0
  6. data/lib/gloo/app/engine.rb +1 -1
  7. data/lib/gloo/app/log.rb +15 -16
  8. data/lib/gloo/app/platform.rb +11 -90
  9. data/lib/gloo/app/prompt.rb +90 -0
  10. data/lib/gloo/app/table.rb +51 -0
  11. data/lib/gloo/core/gloo_system.rb +7 -14
  12. data/lib/gloo/objs/basic/container.rb +1 -2
  13. data/lib/gloo/objs/basic/integer.rb +23 -1
  14. data/lib/gloo/objs/basic/string.rb +116 -1
  15. data/lib/gloo/objs/basic/string_generator.rb +49 -0
  16. data/lib/gloo/objs/basic/text.rb +1 -17
  17. data/lib/gloo/objs/cli/menu.rb +5 -4
  18. data/lib/gloo/objs/cli/select.rb +3 -2
  19. data/lib/gloo/objs/data/markdown.rb +25 -30
  20. data/lib/gloo/objs/data/mysql.rb +39 -27
  21. data/lib/gloo/objs/data/pg.rb +1 -1
  22. data/lib/gloo/objs/data/query_result.rb +4 -9
  23. data/lib/gloo/objs/data/table.rb +1 -1
  24. data/lib/gloo/objs/security/cipher.rb +193 -0
  25. data/lib/gloo/objs/security/password.rb +167 -0
  26. data/lib/gloo/objs/system/file_handle.rb +1 -3
  27. data/lib/gloo/objs/web/json.rb +3 -0
  28. data/lib/gloo/objs/web_svr/page.rb +24 -8
  29. data/lib/gloo/objs/web_svr/partial.rb +7 -6
  30. data/lib/gloo/objs/web_svr/svr.rb +267 -14
  31. data/lib/gloo/verbs/version.rb +1 -1
  32. data/lib/gloo/web_svr/asset.rb +34 -13
  33. data/lib/gloo/web_svr/config.rb +1 -1
  34. data/lib/gloo/web_svr/embedded_renderer.rb +1 -1
  35. data/lib/gloo/web_svr/handler.rb +6 -4
  36. data/lib/gloo/web_svr/request.rb +34 -8
  37. data/lib/gloo/web_svr/response.rb +14 -2
  38. data/lib/gloo/web_svr/response_code.rb +1 -1
  39. data/lib/gloo/web_svr/routing/router.rb +1 -2
  40. data/lib/gloo/web_svr/routing/show_routes.rb +4 -7
  41. data/lib/gloo/web_svr/server.rb +1 -1
  42. data/lib/gloo/web_svr/session.rb +161 -0
  43. data/lib/gloo/web_svr/table_renderer.rb +1 -1
  44. metadata +58 -25
  45. data/lib/gloo/objs/cli/banner.rb +0 -118
  46. data/lib/gloo/objs/cli/bar.rb +0 -133
  47. data/lib/gloo/objs/cli/pastel.rb +0 -104
@@ -11,18 +11,45 @@ module Gloo
11
11
  KEYWORD = 'server'.freeze
12
12
  KEYWORD_SHORT = 'svr'.freeze
13
13
 
14
- # Configuration
15
- SCHEME = 'scheme'.freeze
14
+ # ---------------------------------------------------------------------
15
+ # CONFIGURATION KEYS
16
+ # ---------------------------------------------------------------------
17
+ CONFIG = 'config'.freeze
18
+ SCHEME = 'scheme'.freeze
19
+ HTTP = 'http'.freeze
20
+ HTTPS = 'https'.freeze
16
21
  HOST = 'host'.freeze
17
22
  PORT = 'port'.freeze
23
+ SESSION_NAME = 'session_name'.freeze
24
+ ENCRYPT_KEY = 'encryption_key'.freeze
25
+ ENCRYPT_IV = 'encryption_iv'.freeze
26
+ COOKIE_EXPIRES = 'cookie_expires'.freeze
27
+ COOKIE_PATH = 'cookie_path'.freeze
28
+ DEFAULT_COOKIE_PATH = '/'.freeze
18
29
 
19
30
  # SSL Configuration
20
31
  SSL_CERT = 'ssl_cert'.freeze
21
32
  SSL_KEY = 'ssl_key'.freeze
22
33
 
34
+ # ---------------------------------------------------------------------
35
+ # OTHER KEYS
36
+ # ---------------------------------------------------------------------
37
+
23
38
  # Events
24
39
  ON_START = 'on_start'.freeze
25
40
  ON_STOP = 'on_stop'.freeze
41
+ ON_REQUEST = 'on_request'.freeze
42
+ ON_RESPONSE = 'on_response'.freeze
43
+ RESQUEST_DATA = 'request_data'.freeze
44
+ METHOD = 'method'.freeze
45
+ PATH = 'path'.freeze
46
+ QUERY = 'query'.freeze
47
+ IP = 'ip'.freeze
48
+ RESPONSE_DATA = 'response_data'.freeze
49
+ TYPE = 'type'.freeze
50
+ CODE = 'code'.freeze
51
+ ELAPSED = 'elapsed'.freeze
52
+ DB = 'db'.freeze
26
53
 
27
54
  # Container with pages in the web app.
28
55
  PAGES = 'pages'.freeze
@@ -34,6 +61,9 @@ module Gloo
34
61
  HOME = 'home'.freeze
35
62
  ERR_PAGE = 'error'.freeze
36
63
 
64
+ # Session
65
+ SESSION = 'session'.freeze
66
+
37
67
 
38
68
  # Messages
39
69
  SERVER_NOT_RUNNING = 'The web server is not running!'.freeze
@@ -44,6 +74,7 @@ module Gloo
44
74
  # of the one requested.
45
75
  #
46
76
  attr_accessor :redirect, :router, :asset, :embedded_renderer
77
+ attr_accessor :session
47
78
 
48
79
  #
49
80
  # The name of the object type.
@@ -74,12 +105,29 @@ module Gloo
74
105
  return false
75
106
  end
76
107
 
108
+ #
109
+ # Get the default layout for the app.
110
+ #
111
+ def default_page_layout
112
+ o = find_child LAYOUT
113
+ return nil unless o
114
+
115
+ o = Gloo::Objs::Alias.resolve_alias( @engine, o )
116
+ return o
117
+ end
118
+
119
+
120
+ # ---------------------------------------------------------------------
121
+ # Configuration
122
+ # ---------------------------------------------------------------------
123
+
77
124
  #
78
125
  # Get the Scheme (http or https) from the child object.
79
126
  # Returns nil if there is none.
80
127
  #
81
128
  def scheme_value
82
- scheme = find_child SCHEME
129
+ config = find_child CONFIG
130
+ scheme = config.find_child SCHEME
83
131
  return nil unless scheme
84
132
 
85
133
  return scheme.value
@@ -90,7 +138,8 @@ module Gloo
90
138
  # Returns nil if there is none.
91
139
  #
92
140
  def host_value
93
- host = find_child HOST
141
+ config = find_child CONFIG
142
+ host = config.find_child HOST
94
143
  return nil unless host
95
144
 
96
145
  return host.value
@@ -101,24 +150,163 @@ module Gloo
101
150
  # Returns nil if there is none.
102
151
  #
103
152
  def port_value
104
- port = find_child PORT
153
+ config = find_child CONFIG
154
+ port = config.find_child PORT
105
155
  return nil unless port
106
156
 
107
157
  return port.value
108
158
  end
109
159
 
160
+ #
161
+ # Is this server configured to use a session?
162
+ # It is if theere is a non-empty session name.
163
+ #
164
+ def use_session?
165
+ return ! session_name.blank?
166
+ end
110
167
 
111
168
  #
112
- # Get the default layout for the app.
169
+ # Get the session cookie name.
113
170
  #
114
- def default_page_layout
115
- o = find_child LAYOUT
171
+ def session_name
172
+ config = find_child CONFIG
173
+ session_name = config.find_child SESSION_NAME
174
+ return nil unless session_name
175
+
176
+ name = session_name.value
177
+ return nil if name.blank?
178
+
179
+ return name
180
+ end
181
+
182
+ #
183
+ # Get the key for the encryption cipher.
184
+ #
185
+ def encryption_key
186
+ config = find_child CONFIG
187
+ o = config.find_child ENCRYPT_KEY
116
188
  return nil unless o
117
189
 
118
190
  o = Gloo::Objs::Alias.resolve_alias( @engine, o )
191
+ return o.value
192
+ end
193
+
194
+ #
195
+ # Get the initialization vector for the cipher.
196
+ #
197
+ def encryption_iv
198
+ config = find_child CONFIG
199
+ o = config.find_child ENCRYPT_IV
200
+ return nil unless o
201
+
202
+ o = Gloo::Objs::Alias.resolve_alias( @engine, o )
203
+ return o.value
204
+ end
205
+
206
+ #
207
+ # Get the path for the session cookie.
208
+ # If not specified, use the root path.
209
+ #
210
+ def session_cookie_path
211
+ config = find_child CONFIG
212
+ o = config.find_child COOKIE_PATH
213
+ if o
214
+ return o.value
215
+ else
216
+ return DEFAULT_COOKIE_PATH
217
+ end
218
+ end
219
+
220
+ #
221
+ # Get the expiration time for the session cookie.
222
+ # If not specified, use one week from now.
223
+ #
224
+ def session_cookie_expires
225
+ config = find_child CONFIG
226
+ o = config.find_child COOKIE_EXPIRES
227
+ if o
228
+ dt = Chronic.parse( o.value )
229
+ return dt
230
+ else
231
+ return 1.week.from_now
232
+ end
233
+ end
234
+
235
+ #
236
+ # Should the session cookie be secure?
237
+ # Get the value from the scheme settings/config.
238
+ #
239
+ def session_cookie_secure
240
+ return scheme_value.downcase == HTTPS
241
+ end
242
+
243
+
244
+ # ---------------------------------------------------------------------
245
+ # Session
246
+ # ---------------------------------------------------------------------
247
+
248
+ #
249
+ # Get the session container object.
250
+ # If there is none, one will be created.
251
+ #
252
+ def session_container
253
+ o = find_child SESSION
254
+
255
+ unless o
256
+ o = add_session_container
257
+ end
258
+
119
259
  return o
120
260
  end
121
261
 
262
+ #
263
+ # Add the session container because it is missing.
264
+ #
265
+ def add_session_container
266
+ fac = @engine.factory
267
+ return fac.create_can SESSION, self
268
+ end
269
+
270
+ #
271
+ # Get the data from the session container.
272
+ # Data will be in the form of a hash ( key => value ).
273
+ #
274
+ def get_session_data
275
+ data = {}
276
+
277
+ session_container.children.each do |session_var|
278
+ key = session_var.name
279
+ value = session_var.value
280
+ data[ key ] = value
281
+ end
282
+
283
+ return data
284
+ end
285
+
286
+ #
287
+ # Get the session child object with the given value.
288
+ # Create the child if it does not exist.
289
+ #
290
+ def set_session_var( key, value )
291
+ child_obj = session_container.find_child( key )
292
+ unless child_obj
293
+ fac = @engine.factory
294
+ child_obj = fac.create_string key, value, session_obj
295
+ end
296
+ child_obj.value = value
297
+ end
298
+
299
+ #
300
+ # Clear out all session data.
301
+ # Important to do this after the response is sent
302
+ # to avoid holding on to data that is no longer needed.
303
+ #
304
+ def clear_session_data
305
+ session_container.children.each do |session_var|
306
+ session_var.value = ''
307
+ end
308
+ end
309
+
122
310
 
123
311
  # ---------------------------------------------------------------------
124
312
  # SSL
@@ -190,15 +378,20 @@ module Gloo
190
378
  def add_default_children
191
379
  fac = @engine.factory
192
380
 
193
- fac.create_string SCHEME, 'http', self
194
- fac.create_string HOST, 'localhost', self
195
- fac.create_string PORT, '8080', self
381
+ # Configuration
382
+ config = fac.create_can CONFIG, self
383
+ fac.create_string SCHEME, HTTP, config
384
+ fac.create_string HOST, 'localhost', config
385
+ fac.create_string PORT, '8080', config
196
386
 
197
387
  fac.create_script ON_START, '', self
198
388
  fac.create_script ON_STOP, '', self
199
389
 
390
+ fac.create_alias LAYOUT, nil, self
391
+ fac.create_alias HOME, nil, self
392
+ fac.create_alias ERR_PAGE, nil, self
393
+
200
394
  fac.create_can PAGES, self
201
- fac.create_can HOME, self
202
395
  end
203
396
 
204
397
 
@@ -274,6 +467,8 @@ module Gloo
274
467
 
275
468
  @embedded_renderer = Gloo::WebSvr::EmbeddedRenderer.new( @engine, self )
276
469
 
470
+ @session = Gloo::WebSvr::Session.new( @engine, self )
471
+
277
472
  run_on_start
278
473
  @engine.log.info "Web server started and listening…"
279
474
  end
@@ -283,6 +478,10 @@ module Gloo
283
478
  #
284
479
  def stop
285
480
  @engine.log.info "Stopping web server…"
481
+
482
+ # Last chance to clear out session data.
483
+ clear_session_data
484
+
286
485
  @web_server.stop
287
486
  @web_server = nil
288
487
  @router = nil
@@ -297,7 +496,7 @@ module Gloo
297
496
  # ---------------------------------------------------------------------
298
497
 
299
498
  #
300
- # Run the on render script if there is one.
499
+ # Run the on start script if there is one.
301
500
  #
302
501
  def run_on_start
303
502
  o = find_child ON_START
@@ -307,7 +506,7 @@ module Gloo
307
506
  end
308
507
 
309
508
  #
310
- # Run the on rendered script if there is one.
509
+ # Run the on stop script if there is one.
311
510
  #
312
511
  def run_on_stop
313
512
  o = find_child ON_STOP
@@ -316,6 +515,60 @@ module Gloo
316
515
  Gloo::Exec::Dispatch.message( @engine, 'run', o )
317
516
  end
318
517
 
518
+ #
519
+ # Run the on request script if there is one.
520
+ #
521
+ def run_on_request
522
+ o = find_child ON_REQUEST
523
+ return unless o
524
+ o = Gloo::Objs::Alias.resolve_alias( @engine, o )
525
+
526
+ Gloo::Exec::Dispatch.message( @engine, 'run', o )
527
+ end
528
+
529
+ #
530
+ # Run the on response script if there is one.
531
+ #
532
+ def run_on_response
533
+ o = find_child ON_RESPONSE
534
+ return unless o
535
+ o = Gloo::Objs::Alias.resolve_alias( @engine, o )
536
+
537
+ Gloo::Exec::Dispatch.message( @engine, 'run', o )
538
+ end
539
+
540
+ #
541
+ # Set up the request data for the page load.
542
+ # This is done before the on_request event is fired.
543
+ #
544
+ def set_request_data( request )
545
+ data = find_child RESQUEST_DATA
546
+ return unless data
547
+ data = Gloo::Objs::Alias.resolve_alias( @engine, data )
548
+
549
+ data.find_child( METHOD )&.set_value( request.method )
550
+ data.find_child( HOST )&.set_value( request.host )
551
+ data.find_child( PATH )&.set_value( request.path )
552
+ data.find_child( QUERY )&.set_value( request.query )
553
+ data.find_child( IP )&.set_value( request.ip )
554
+ end
555
+
556
+ #
557
+ # Set up the response data for the page load.
558
+ # This is done after the page is rendered and before
559
+ # the on_response event is fired.
560
+ #
561
+ def set_response_data( request, response )
562
+ data = find_child RESPONSE_DATA
563
+ return unless data
564
+ data = Gloo::Objs::Alias.resolve_alias( @engine, data )
565
+
566
+ data.find_child( ELAPSED )&.set_value( request.elapsed )
567
+ data.find_child( DB )&.set_value( request.db )
568
+ data.find_child( TYPE )&.set_value( response.type )
569
+ data.find_child( CODE )&.set_value( response.code )
570
+ end
571
+
319
572
 
320
573
  # ---------------------------------------------------------------------
321
574
  # Pages and standard elements.
@@ -55,7 +55,7 @@ module Gloo
55
55
  def show_vers_notes
56
56
  @engine.log.show "Gloo version notes..."
57
57
  notes = Gloo::App::Info.get_version_notes
58
- @engine.platform.show( notes, false, true )
58
+ @engine.platform.show notes
59
59
  end
60
60
 
61
61
  #
@@ -1,5 +1,5 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # A helper class for static assets.
5
5
  #
@@ -155,6 +155,26 @@ module Gloo
155
155
  @factory.create_can( JAVASCRIPT_FOLDER, @assets )
156
156
  end
157
157
 
158
+ #
159
+ # Traverse the given folder and add all files to the container.
160
+ # This is a recursive method and look look for files in subfolders.
161
+ #
162
+ def add_files_in_folder( folder, container, path )
163
+ Dir.each_child( folder ) do |name|
164
+ pn = File.join( path, name )
165
+ full_path = File.join( folder, name )
166
+
167
+ if File.directory? full_path
168
+ child = container.find_child( name )
169
+ child = @factory.create_can( name, container ) if child.nil?
170
+
171
+ add_files_in_folder( full_path, child, pn )
172
+ else
173
+ add_file_obj( container, name, pn )
174
+ end
175
+ end
176
+ end
177
+
158
178
  #
159
179
  # Add the images to the web server pages.
160
180
  #
@@ -165,10 +185,7 @@ module Gloo
165
185
 
166
186
  # for each file in the images folder
167
187
  # create a file object and add it to the images container
168
- Dir.each_child( image_folder ) do |name|
169
- pn = File.join( IMAGE_FOLDER, name )
170
- add_file_obj( @images, name, pn )
171
- end
188
+ add_files_in_folder( image_folder, @images, IMAGE_FOLDER )
172
189
  end
173
190
 
174
191
  #
@@ -181,10 +198,12 @@ module Gloo
181
198
 
182
199
  # for each file in the stylesheets folder
183
200
  # create a file object and add it to the stylesheets container
184
- Dir.each_child( stylesheet_folder ) do |name|
185
- pn = File.join( STYLESHEET_FOLDER, name )
186
- add_file_obj( @stylesheets, name, pn )
187
- end
201
+ add_files_in_folder( stylesheet_folder, @stylesheets, STYLESHEET_FOLDER )
202
+
203
+ # Dir.each_child( stylesheet_folder ) do |name|
204
+ # pn = File.join( STYLESHEET_FOLDER, name )
205
+ # add_file_obj( @stylesheets, name, pn )
206
+ # end
188
207
  end
189
208
 
190
209
  #
@@ -197,10 +216,12 @@ module Gloo
197
216
 
198
217
  # for each file in the javascript folder
199
218
  # create a file object and add it to the javascript container
200
- Dir.each_child( javascript_folder ) do |name|
201
- pn = File.join( JAVASCRIPT_FOLDER, name )
202
- add_file_obj( @javascript, name, pn )
203
- end
219
+ add_files_in_folder( javascript_folder, @javascript, JAVASCRIPT_FOLDER )
220
+
221
+ # Dir.each_child( javascript_folder ) do |name|
222
+ # pn = File.join( JAVASCRIPT_FOLDER, name )
223
+ # add_file_obj( @javascript, name, pn )
224
+ # end
204
225
  end
205
226
 
206
227
  #
@@ -1,5 +1,5 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # Configuration for a gloo web server.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # A helper class used to render parameters (ERB) in text.
5
5
  # Also uses helper functions to render.
@@ -1,5 +1,5 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # Web application request handler.
5
5
  # Takes a request and does what is needed to create a response.
@@ -41,13 +41,15 @@ module Gloo
41
41
  request.id = id
42
42
  if page
43
43
  if page.is_a? Gloo::Objs::FileHandle
44
- return handle_file page
44
+ result = handle_file page
45
45
  else
46
- return handle_page page
46
+ result = handle_page page
47
47
  end
48
+ else
49
+ result = server_error_result
48
50
  end
49
51
 
50
- return server_error_result
52
+ return result
51
53
  end
52
54
 
53
55
  #
@@ -1,5 +1,5 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # A web Request for a page, action, or static resource.
5
5
  #
@@ -9,6 +9,10 @@
9
9
  # API - returns JSON instead of HTML (but is that different from Web Page?)
10
10
  # Static Resource - File, PDF, Image, etc.
11
11
  #
12
+ #
13
+ # See More doc here:
14
+ # https://www.rubydoc.info/gems/rack/Rack/Request/Helpers#path-instance_method
15
+ #
12
16
 
13
17
  module Gloo
14
18
  module WebSvr
@@ -19,7 +23,8 @@ module Gloo
19
23
  HTTP_HOST = 'HTTP_HOST'.freeze
20
24
  QUERY_STRING = 'QUERY_STRING'.freeze
21
25
 
22
- attr_reader :method, :host, :path, :query, :body
26
+ attr_reader :method, :host, :path, :query, :body, :ip
27
+ attr_reader :db, :elapsed
23
28
  attr_accessor :id
24
29
 
25
30
 
@@ -50,11 +55,22 @@ module Gloo
50
55
  #
51
56
  def process
52
57
  start_timer
58
+
59
+ # Run the on_request script if there is one.
60
+ @handler.server_obj.set_request_data self
61
+ @handler.server_obj.run_on_request
62
+
53
63
  result = @handler.handle self
54
64
  finish_timer
65
+
66
+ # Run the on_response script if there is one.
67
+ @handler.server_obj.set_response_data self, result
68
+ @handler.server_obj.run_on_response
69
+
55
70
  return result
56
71
  end
57
72
 
73
+
58
74
  # ---------------------------------------------------------------------
59
75
  # ENV
60
76
  # ---------------------------------------------------------------------
@@ -63,10 +79,20 @@ module Gloo
63
79
  # Write the request information to the log.
64
80
  #
65
81
  def detect_env
66
- @method = @env[ REQUEST_METHOD ]
67
- @path = @env[ REQUEST_PATH ]
68
- @host = @env[ HTTP_HOST ]
69
- @query = @env[ QUERY_STRING ]
82
+ req = Rack::Request.new( @env )
83
+
84
+ @method = req.request_method
85
+ @path = req.path
86
+ @host = req.host_with_port
87
+ @query = req.query_string
88
+ @ip = req.ip
89
+
90
+ # @method = @env[ REQUEST_METHOD ]
91
+ # @path = @env[ REQUEST_PATH ]
92
+ # @host = @env[ HTTP_HOST ]
93
+ # @query = @env[ QUERY_STRING ]
94
+
95
+ @handler.server_obj.session.set_session_data_for_request( @env )
70
96
 
71
97
  @body = @env[ 'rack.input' ].read
72
98
  @body = Rack::Utils.parse_query @body
@@ -92,8 +118,8 @@ module Gloo
92
118
  def finish_timer
93
119
  @finish = Time.now
94
120
  @elapsed = ( ( @finish - @start ) * 1000.0 ).round(2)
95
- db = @engine.running_app.db_time
96
- @log.info "*** Web request complete. DB: #{db} ms. Elapsed time: #{@elapsed} ms"
121
+ @db = @engine.running_app.db_time
122
+ @log.info "*** Web request complete. DB: #{@db} ms. Elapsed time: #{@elapsed} ms"
97
123
  end
98
124
 
99
125
 
@@ -1,5 +1,5 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # The Response for a web Request.
5
5
  #
@@ -88,7 +88,19 @@ module Gloo
88
88
  # Get the headers for the response.
89
89
  #
90
90
  def headers
91
- return { CONTENT_TYPE => @type }
91
+ #
92
+ # TO DO: Add more cookie headers here.
93
+ #
94
+ # https://stackoverflow.com/questions/3295083/how-do-i-set-a-cookie-with-a-ruby-rack-middleware-component
95
+ # https://www.rubydoc.info/gems/rack/1.4.7/Rack/Session/Cookie
96
+ #
97
+
98
+ headers = { CONTENT_TYPE => @type }
99
+
100
+ session = @engine&.running_app&.obj&.session
101
+ headers = session.add_session_for_response( headers ) if session
102
+
103
+ return headers
92
104
  end
93
105
 
94
106
  #
@@ -1,5 +1,5 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # Standard Response Codes.
5
5
  #
@@ -1,9 +1,8 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # A helper class for page routing.
5
5
  #
6
- require 'tty-table'
7
6
 
8
7
  module Gloo
9
8
  module WebSvr
@@ -1,9 +1,8 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # A helper class for to show routes for a running app.
5
5
  #
6
- require 'tty-table'
7
6
 
8
7
  module Gloo
9
8
  module WebSvr
@@ -77,11 +76,9 @@ module Gloo
77
76
  # Show the Routes title.
78
77
  #
79
78
  def show_table
80
- @log.show "\n\tRoutes in Running Web App\n", :white
81
-
82
- table = TTY::Table.new( headers, @found_routes )
83
- renderer = TTY::Table::Renderer::Unicode.new( table, padding: [0,1] )
84
- puts renderer.render
79
+ puts RETURN
80
+ title = "Routes in Running Web App"
81
+ @engine.platform.table.show headers, @found_routes, title
85
82
  puts RETURN
86
83
  end
87
84
 
@@ -1,5 +1,5 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
3
  #
4
4
  # Starting work on web server inside gloo.
5
5
  #