Module: Snails::Main
- Defined in:
- runtime/snails/main/dispatch.rbs,
runtime/snails/main/server.rbs,
runtime/snails/main/dispatch.rb,
runtime/snails/main/server.rb
Class Method Summary collapse
-
.configure_database! ⇒ void
configure the process-wide
Sqlx::Databasefrom the app'sconfig/database.rb. -
.dispatch(req, res) ⇒ void
the default request pipeline called by
Tep::App#dispatchfor every request: match, wire the typed request, run the controller, and copy status/body/content-type back. -
.request_params(req, path_params) ⇒ Hash{String => Object}?
the controller's params: body fields, the query string over them, and the route's path captures over both, each half nested by
ActionDispatch::ParamBuilder. -
.route_table ⇒ Array<ActionDispatch::Router::Route>
the composed route table, built once on first use.
-
.start ⇒ void
parse the CLI/env, configure the database, require connection leases (the SQLite adapter refuses a database access with no lease from here on; the PostgreSQL adapter has one shared connection, so this is a no-op), register the job executor, and run the green-thread-per-connection server.
Class Method Details
.configure_database! ⇒ void
configure the process-wide Sqlx::Database from the app's
config/database.rb. Adapter-neutral: the selected backend reads its own
source. No DDL here; schema is applied by an explicit step (the core
Snails::SchemaLoader in the harness gate, or the app's own script).
11 |
# File 'runtime/snails/main/server.rb', line 11
def self.configure_database!: () -> untyped
|
.dispatch(req, res) ⇒ void
the default request pipeline called by Tep::App#dispatch for every
request: match, wire the typed request, run the controller, and copy
status/body/content-type back. API-only: request_format defaults to
JSON, and a route miss or malformed params returns the same JSON an app's
endpoints do; a controller's Sqlx::RecordNotFound becomes a JSON 404,
and a required parameter the client did not send becomes a JSON 400.
A HEAD request matches the GET route it mirrors and reaches the action as HEAD; the server sends that response's status and headers without the message body.
68 |
# File 'runtime/snails/main/dispatch.rb', line 68
def self.dispatch: (untyped req, untyped res) -> untyped
|
.request_params(req, path_params) ⇒ Hash{String => Object}?
the controller's params: body fields, the query string over them, and the
route's path captures over both, each half nested by
ActionDispatch::ParamBuilder.
Multipart and JSON fields are flattened by name, so a repeated field keeps its last value; urlencoded and query params keep every value.
29 |
# File 'runtime/snails/main/dispatch.rb', line 29
def self.request_params: (untyped req, Hash[String, String] path_params) -> Hash[String, untyped]?
|
.route_table ⇒ Array<ActionDispatch::Router::Route>
the composed route table, built once on first use.
The app's config/routes.rb declares Snails::RouteTable.table; it is
memoized because Snails::RouteTable.table constructs every Route on each
call.
12 |
# File 'runtime/snails/main/dispatch.rb', line 12
def self.route_table: () -> Array[::ActionDispatch::Router::Route]
|
.start ⇒ void
parse the CLI/env, configure the database, require connection leases (the SQLite adapter refuses a database access with no lease from here on; the PostgreSQL adapter has one shared connection, so this is a no-op), register the job executor, and run the green-thread-per-connection server.
21 |
# File 'runtime/snails/main/server.rb', line 21
def self.start: () -> untyped
|