-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97ac2cd
commit 7e41cbc
Showing
1 changed file
with
6 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
""" CORS Middleware """ | ||
"""CORS Middleware.""" | ||
|
||
from masonite.helpers import config | ||
from masonite.request import Request | ||
|
||
|
||
class CorsMiddleware: | ||
"""Appends CORS headers to HTTP response | ||
"""Appends CORS headers to HTTP response. | ||
Put any CORS middleware you need as a CORS dictionary inside your | ||
middleware config file. | ||
Put any CORS middleware you need as a CORS dictionary inside your | ||
middleware config file. | ||
""" | ||
|
||
def __init__(self, request: Request): | ||
"""Inject Any Dependencies From The Service Container | ||
"""Inject Any Dependencies From The Service Container. | ||
Arguments: | ||
Request {masonite.request.Request} -- The Masonite request object | ||
""" | ||
self.request = request | ||
|
||
def after(self): | ||
"""Run This Middleware After The Route Executes | ||
""" | ||
"""Run This Middleware After The Route Executes.""" | ||
headers = config('middleware.cors') or {} | ||
self.request.header(headers) |