Class: Belt::WelcomeController

Inherits:
BeltController::Base show all
Defined in:
lib/belt/controllers/welcome_controller.rb

Overview

Gem-embedded welcome controller that serves the default "it works!" page.

Resolved via the ActionRouter's Belt

namespace fallback when no app-defined

WelcomeController exists. Gets replaced once the user defines their own root route.

Dual format:

- Browser / no Accept preference → HTML hero + stack check
- Accept: application/json (SPA / apiClient) → JSON payload for the React shell

The hero image (lib/belt/assets/belt-default.jpg) is the single source of truth — HTML embeds it, and JSON returns the same bytes as a data URI so the SPA matches.

Constant Summary collapse

ASSETS_DIR =
File.expand_path('../assets', __dir__)
SCAFFOLD_HINT_CMD =

Scaffold gives model + controller + routes + schema (not model-only).

'belt generate scaffold Post title content:text'

Constants included from BeltController::ImplicitResponse

BeltController::ImplicitResponse::FRAMEWORK_IVARS

Instance Attribute Summary

Attributes inherited from BeltController::Base

#body, #event

Instance Method Summary collapse

Methods inherited from BeltController::Base

#action_name, #admin?, after_action, after_actions, all_after_actions, all_before_actions, all_rescue_handlers, all_skipped_before_actions, #authenticate!, before_action, before_actions, #current_user_id, default_format, default_format=, #dispatch, #employee?, #initialize, #params, rescue_from, rescue_handlers, skip_before_action, skipped_before_actions, #user_groups

Methods included from Rendering

included

Methods included from Helpers::Response

#cors_headers, #error_response, #handle_error_and_respond, #head, #html_response, #response_status, #success_response

Constructor Details

This class inherits a constructor from BeltController::Base

Instance Method Details

#showObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/belt/controllers/welcome_controller.rb', line 23

def show
  @title = ENV.fetch('WELCOME_TITLE', 'Welcome to Belt')
  @subtitle = ENV.fetch('WELCOME_SUBTITLE', 'API Gateway → Lambda → DynamoDB — all connected.')
  @dynamodb_connected = dynamodb_connected?
  @scaffold_hint_cmd = SCAFFOLD_HINT_CMD

  return success_response(welcome_payload) if wants_json?

  @css = welcome_css
  @background_image = background_image_base64
  render
end