9
9
from masonite .request import Request
10
10
from masonite .routes import Route
11
11
from masonite .storage import Storage
12
- from config import middleware
12
+ from masonite .app import App
13
+ from config import middleware , application
13
14
from pydoc import locate
14
15
15
16
16
-
17
17
# Run once and only once the server is ran
18
18
# This will not actually compile if the libsass module in not installed
19
19
Storage ().compile_sass ()
@@ -23,6 +23,27 @@ def app(environ, start_response):
23
23
os .environ .setdefault ('REQUEST_METHOD' , environ ['REQUEST_METHOD' ])
24
24
os .environ .setdefault ('URI_PATH' , environ ['PATH_INFO' ])
25
25
26
+ # Instantiate the Service Container
27
+ app = App ()
28
+
29
+ # Instantiate the Request object.
30
+ # This is the `request` object passed into controller methods
31
+ request = Request (environ )
32
+
33
+ # Bind the Request object into the container
34
+ app .bind ('Request' , request )
35
+
36
+ # Execute all the register methods in all containers
37
+ for provider in application .PROVIDERS :
38
+ locate (provider )().load_app (app ).register ()
39
+
40
+ # Execute all the boot methods in all containers
41
+ for provider in application .PROVIDERS :
42
+ app .resolve (locate (provider )().boot )
43
+
44
+ # Load the container into the request
45
+ app .make ('Request' ).load_app (app )
46
+
26
47
router = Route (environ )
27
48
28
49
if router .is_post ():
@@ -37,10 +58,6 @@ def app(environ, start_response):
37
58
import routes .web
38
59
routes = routes .web .ROUTES
39
60
40
- # Instantiate the Request object.
41
- # This is the `request` object passed into controller methods
42
- request = Request (environ )
43
-
44
61
# Check all http routes
45
62
for route in routes :
46
63
# Compiles the given route to regex
@@ -88,7 +105,7 @@ def app(environ, start_response):
88
105
# Get the data from the route. This data is typically the output
89
106
# of the controller method
90
107
if not request .redirect_url :
91
- data = router .get (route .route , route .output ( request ))
108
+ data = router .get (route .route , app . resolve ( route .output ))
92
109
93
110
# Loads the request in so the middleware specified is able to use the
94
111
# request object. This is after middleware and is ran after the request
0 commit comments