Skip to content

Commit 1d4e4e5

Browse files
Add protocol HTTP application boundary.
1 parent 2914915 commit 1d4e4e5

88 files changed

Lines changed: 1773 additions & 749 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bake/utopia/site.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def initialize(...)
1818
SETUP_ROOT = File.expand_path("../../setup", __dir__)
1919

2020
# Configuration files which should be installed/updated:
21-
CONFIGURATION_FILES = [".gitignore", "config.ru", "config/environment.rb", "falcon.rb", "gems.rb", "bake.rb", "test/website.rb", "fixtures/website.rb"]
21+
CONFIGURATION_FILES = [".gitignore", "config/application.rb", "config/environment.rb", "falcon.rb", "gems.rb", "bake.rb", "test/website.rb", "fixtures/website.rb"]
2222

2323
# Directories that should exist:
2424
DIRECTORIES = ["config", "lib", "pages", "public", "bake", "fixtures", "test"]

bake/utopia/static.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ def generate(output_path: "static")
88
require "async/io"
99
require "async/http/endpoint"
1010
require "async/container"
11+
require "utopia/application"
1112

12-
config_path = File.join(Dir.pwd, "config.ru")
13+
application_path = File.join(Dir.pwd, Utopia::Application::PATH)
1314
container_class = Async::Container::Threaded
1415
server_port = 9090
1516

16-
app, options = Rack::Builder.parse_file(config_path)
17+
app = Utopia::Application.load(application_path)
1718

1819
container = container_class.run(count: 2) do
1920
Async do

config/external.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
utopia-project:
22
url: https://github.com/socketry/utopia-project.git
3-
command: bundle exec bake test
4-
www.codeotaku.com:
5-
url: https://github.com/ioquatix/www.codeotaku.com.git
3+
branch: v3-protocol-application
64
command: bundle exec bake test

context/getting-started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This guide explains how to set up a `utopia` website for local development and d
44

55
## Installation
66

7-
Utopia is built on Ruby and Rack. Therefore, Ruby (suggested 2.0+) should be installed and working. Then, to install `utopia` and all required dependencies, run:
7+
Utopia is built on Ruby. Therefore, Ruby should be installed and working. Then, to install `utopia` and all required dependencies, run:
88

99
~~~ bash
1010
$ gem install utopia
@@ -32,7 +32,7 @@ You will now have a basic template site running on `https://localhost:9292`.
3232
Utopia includes a redirection middleware to redirect all root-level requests to a given URI. The default being `/welcome/index`:
3333

3434
```ruby
35-
# in config.ru
35+
# in config/application.rb
3636

3737
use Utopia::Redirection::Rewrite,
3838
"/" => "/welcome/index"
@@ -84,7 +84,7 @@ website
8484

8585
Least Coverage:
8686
pages/_page.xnode: 6 lines not executed!
87-
config.ru: 4 lines not executed!
87+
config/application.rb: 4 lines not executed!
8888
pages/welcome/index.xnode: 2 lines not executed!
8989
pages/_heading.xnode: 1 lines not executed!
9090

context/index.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ files:
1313
and deployment.
1414
- path: middleware.md
1515
title: Middleware
16-
description: This guide gives an overview of the different Rack middleware used
16+
description: This guide gives an overview of the different middleware used
1717
by Utopia.
1818
- path: server-setup.md
1919
title: Server Setup

context/middleware.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Middleware
22

3-
This guide gives an overview of the different Rack middleware used by Utopia.
3+
This guide gives an overview of the different middleware used by Utopia.
44

55
## Static
66

7-
The {ruby Utopia::Static} middleware services static files efficiently. By default, it works with `Rack::Sendfile` and supports `ETag` based caching. Normally, you'd prefer to put static files into `public/_static` but it's also acceptable to put static content into `pages/` if it makes sense.
7+
The {ruby Utopia::Static} middleware services static files efficiently and supports `ETag` based caching. Normally, you'd prefer to put static files into `public/_static` but it's also acceptable to put static content into `pages/` if it makes sense.
88

99
~~~ ruby
1010
use Utopia::Static,
@@ -90,7 +90,7 @@ def passthrough(request, path)
9090

9191
# Succeed the request and immediately respond.
9292
# def succeed!(status: 200, headers: {}, **options)
93-
# options may include content: string or body: Enumerable (as per Rack specifications
93+
# options may include content: String or body: Enumerable.
9494

9595
suceed!
9696
end
@@ -108,7 +108,7 @@ end
108108

109109
on "edit" do |request, path|
110110
if request.post?
111-
@user.update_attributes(request[:user])
111+
@user.update_attributes(request.arguments["user"])
112112
end
113113
end
114114

@@ -155,3 +155,9 @@ use Utopia::Session,
155155
```
156156

157157
All session data is stored on the client, but it's encrypted with a salt and the secret key. It is impossible for the client to decrypt the data without the secret stored on the server.
158+
159+
When the middleware is installed, the session is available on the request:
160+
161+
```ruby
162+
request.session[:user_id] = user.id
163+
```

fixtures/a_rack_application.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

gems.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
group :development do
2323
gem "json"
24-
gem "rackula"
2524
end
2625

2726
group :test do
@@ -40,6 +39,4 @@
4039
gem "bake-test-external"
4140

4241
gem "benchmark-ips"
43-
44-
gem "rack-test"
4542
end

guides/getting-started/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This guide explains how to set up a `utopia` website for local development and d
44

55
## Installation
66

7-
Utopia is built on Ruby and Rack. Therefore, Ruby (suggested 2.0+) should be installed and working. Then, to install `utopia` and all required dependencies, run:
7+
Utopia is built on Ruby. Therefore, Ruby should be installed and working. Then, to install `utopia` and all required dependencies, run:
88

99
~~~ bash
1010
$ gem install utopia
@@ -32,7 +32,7 @@ You will now have a basic template site running on `https://localhost:9292`.
3232
Utopia includes a redirection middleware to redirect all root-level requests to a given URI. The default being `/welcome/index`:
3333

3434
```ruby
35-
# in config.ru
35+
# in config/application.rb
3636

3737
use Utopia::Redirection::Rewrite,
3838
"/" => "/welcome/index"
@@ -84,7 +84,7 @@ website
8484

8585
Least Coverage:
8686
pages/_page.xnode: 6 lines not executed!
87-
config.ru: 4 lines not executed!
87+
config/application.rb: 4 lines not executed!
8888
pages/welcome/index.xnode: 2 lines not executed!
8989
pages/_heading.xnode: 1 lines not executed!
9090

guides/middleware/readme.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Middleware
22

3-
This guide gives an overview of the different Rack middleware used by Utopia.
3+
This guide gives an overview of the different middleware used by Utopia.
44

55
## Static
66

7-
The {ruby Utopia::Static} middleware services static files efficiently. By default, it works with `Rack::Sendfile` and supports `ETag` based caching. Normally, you'd prefer to put static files into `public/_static` but it's also acceptable to put static content into `pages/` if it makes sense.
7+
The {ruby Utopia::Static} middleware services static files efficiently and supports `ETag` based caching. Normally, you'd prefer to put static files into `public/_static` but it's also acceptable to put static content into `pages/` if it makes sense.
88

99
~~~ ruby
1010
use Utopia::Static,
@@ -90,7 +90,7 @@ def passthrough(request, path)
9090

9191
# Succeed the request and immediately respond.
9292
# def succeed!(status: 200, headers: {}, **options)
93-
# options may include content: string or body: Enumerable (as per Rack specifications
93+
# options may include content: String or body: Enumerable.
9494

9595
suceed!
9696
end
@@ -108,7 +108,7 @@ end
108108

109109
on "edit" do |request, path|
110110
if request.post?
111-
@user.update_attributes(request[:user])
111+
@user.update_attributes(request.arguments["user"])
112112
end
113113
end
114114

@@ -155,3 +155,9 @@ use Utopia::Session,
155155
```
156156

157157
All session data is stored on the client, but it's encrypted with a salt and the secret key. It is impossible for the client to decrypt the data without the secret stored on the server.
158+
159+
When the middleware is installed, the session is available on the request:
160+
161+
```ruby
162+
request.session[:user_id] = user.id
163+
```

0 commit comments

Comments
 (0)