Skip to content

Commit 9561a9f

Browse files
committed
Update to version 4.0.0
1 parent 706532e commit 9561a9f

15 files changed

Lines changed: 137 additions & 56 deletions

docs/advanced_routing.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@ end
1919

2020
class Application < Grip::Application
2121
def initialize
22-
super(environment: "development")
22+
super(
23+
environment: ENV["ENVIRONMENT"]? || "production"
24+
handlers: [
25+
Grip::Handlers::Pipeline.new,
26+
Grip::Handlers::HTTP.new
27+
] of HTTP::Handler
28+
)
29+
30+
routes()
31+
end
2332

33+
def routes()
2434
pipeline :api, [
2535
AuthorizationHandler.new
2636
]

docs/application.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,6 @@ class Application < Grip::Application
5050
end
5151
```
5252

53-
### router
54-
55-
The router of the application.
56-
57-
```ruby
58-
class Application < Grip::Application
59-
def router : Array(HTTP::Handler)
60-
[] of HTTP::Handler
61-
end
62-
end
63-
```
64-
6553
### server
6654

6755
The server of the application.
@@ -76,7 +64,7 @@ end
7664

7765
### key_file
7866

79-
The key_file of the application.
67+
The SSL key file location of the application.
8068

8169
```ruby
8270
class Application < Grip::Application
@@ -88,7 +76,7 @@ end
8876

8977
### cert_file
9078

91-
The cert_file of the application.
79+
The SSL certificate file location of the application.
9280

9381
```ruby
9482
class Application < Grip::Application

docs/basic_routing.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,18 @@ end
1010

1111
class Application < Grip::Application
1212
def initialize
13-
super(environment: "development")
13+
def initialize
14+
super(
15+
environment: ENV["ENVIRONMENT"]? || "production"
16+
handlers: [
17+
Grip::Handlers::HTTP.new
18+
] of HTTP::Handler
19+
)
1420

21+
routes()
22+
end
23+
24+
def routes()
1525
# The routing occurs via the `get` macro which instantiates the controller class and assigns a route
1626
# to the routing mechanism.
1727
get "/", DemoController

docs/error_handling.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ end
2121

2222
class Application < Grip::Application
2323
def initialize
24-
super(environment: "development")
24+
super(
25+
environment: ENV["ENVIRONMENT"]? || "production"
26+
handlers: [
27+
Grip::Handlers::Exception.new,
28+
] of HTTP::Handler
29+
)
2530

31+
routes()
32+
end
33+
34+
def routes()
2635
exception Grip::Exceptions::Forbidden, ForbiddenController
2736
end
2837
end
@@ -64,8 +73,17 @@ end
6473

6574
class Application < Grip::Application
6675
def initialize
67-
super(environment: "development")
76+
super(
77+
environment: ENV["ENVIRONMENT"]? || "production"
78+
handlers: [
79+
Grip::Handlers::Exception.new,
80+
] of HTTP::Handler
81+
)
82+
83+
routes()
84+
end
6885

86+
def routes()
6987
exception NotImplementedError, FallbackController
7088
end
7189
end

docs/forward.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@ end
1313

1414
class Application < Grip::Application
1515
def initialize
16-
super(environment: "development")
16+
super(
17+
environment: ENV["ENVIRONMENT"]? || "production"
18+
handlers: [
19+
Grip::Handlers::HTTP.new,
20+
] of HTTP::Handler
21+
)
22+
23+
routes()
24+
end
25+
26+
def routes()
1727

1828
# Forward macro simply routes the matched requests to a certain Base controller
1929
# which contains a single call/1 function.

docs/getting_started.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,17 @@ end
3232
3333
class Application < Grip::Application
3434
def initialize
35-
super(environment: "development")
35+
super(
36+
environment: ENV["ENVIRONMENT"]? || "production"
37+
handlers: [
38+
Grip::Handlers::HTTP.new,
39+
] of HTTP::Handler
40+
)
3641
42+
routes()
43+
end
44+
45+
def routes()
3746
get "/", DemoController
3847
end
3948
end

docs/intermediate_routing.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@ end
1919

2020
class Application < Grip::Application
2121
def initialize
22-
super(environment: "development")
22+
super(
23+
environment: ENV["ENVIRONMENT"]? || "production"
24+
handlers: [
25+
Grip::Handlers::HTTP.new,
26+
] of HTTP::Handler
27+
)
2328

29+
routes()
30+
end
31+
32+
def routes()
2433
# The routing occurs via the `get` macro which instantiates the controller class and assigns a route
2534
# to the routing mechanism, the `as` keyword creates a Proc(Context, Context) and wraps it around
2635
# the index/1 function of the DemoController.

docs/pipe_middleware.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,18 @@ end
2121

2222
class Application < Grip::Application
2323
def initialize
24-
super(environment: "development")
24+
super(
25+
environment: ENV["ENVIRONMENT"]? || "production"
26+
handlers: [
27+
Grip::Handlers::Pipeline.new,
28+
Grip::Handlers::HTTP.new,
29+
] of HTTP::Handler
30+
)
31+
32+
routes()
33+
end
2534

35+
def routes()
2636
# Creating a pipeline with a single pipe to be routed through.
2737
pipeline :web, [
2838
DemoPipe.new

docs/raw_middleware.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,19 @@ class DemoHandler
66

77
def call(context : HTTP::Server::Context) : HTTP::Server::Context
88
# Mutate the context and pass it on to the next handler.
9+
call_next(context)
910
end
1011
end
1112

1213
class Application < Grip::Application
1314
def initialize
14-
super(environment: "development")
15-
16-
# By default the router has 4 entries, if you insert a handler
17-
# before the exception handler any exception that might occur in
18-
# your newly inserted handler will not be handled and might crash the application.
19-
#
20-
# [
21-
# exception_handler,
22-
# pipeline_handler,
23-
# websocket_handler,
24-
# http_handler,
25-
# ]
26-
router.insert(1, DemoHandler.new)
15+
super(
16+
environment: ENV["ENVIRONMENT"]? || "production"
17+
handlers: [
18+
DemoHandler.new,
19+
Grip::Handlers::HTTP.new,
20+
] of HTTP::Handler
21+
)
2722
end
2823
end
2924
```

docs/scope.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@ end
1010

1111
class Application < Grip::Application
1212
def initialize
13-
super(environment: "development")
13+
super(
14+
environment: ENV["ENVIRONMENT"]? || "production"
15+
handlers: [
16+
Grip::Handlers::HTTP.new,
17+
] of HTTP::Handler
18+
)
1419

20+
routes()
21+
end
22+
23+
def routes()
1524
# The route gets built from the ground starting from the lowest GET /, to the top /api/v1.
1625
scope "/api/v1" do
1726
get "/", DemoController

0 commit comments

Comments
 (0)