Skip to content

Commit 393bdfe

Browse files
committed
fix: minor bugs
1 parent 7c4365d commit 393bdfe

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

lightbug_http/middleware/basicauth.mojo

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct BasicAuthMiddleware(Middleware):
1010
fn set_next(self, next: Middleware):
1111
self.next = next
1212

13-
fn __init__(self, username: String, password: String):
13+
fn __init__(inout self, username: String, password: String):
1414
self.username = username
1515
self.password = password
1616

lightbug_http/middleware/cors.mojo

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct CorsMiddleware(Middleware):
99
fn set_next(self, next: Middleware):
1010
self.next = next
1111

12-
fn __init__(self, allow_origin: String):
12+
fn __init__(inout self, allow_origin: String):
1313
self.allow_origin = allow_origin
1414

1515
fn call(self, context: Context) -> HTTPResponse:

lightbug_http/middleware/notfound.mojo

+5
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@ from lightbug_http.middleware.helpers import NotFound
33
## NotFound middleware returns a 404 response if no other middleware handles the request. It is a leaf node and always add at the end of the middleware chain
44
@value
55
struct NotFoundMiddleware(Middleware):
6+
var next: Middleware
7+
8+
fn set_next(self, next: Middleware):
9+
self.next = next
10+
611
fn call(self, context: Context) -> HTTPResponse:
712
return NotFound("Not Found")

lightbug_http/middleware/router.mojo

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct RouterMiddleware[HTTPHandlerType: HTTPHandler](Middleware):
1717
fn set_next(self, next: Middleware):
1818
self.next = next
1919

20-
fn add(self, method: String, route: String, handler: HTTPHandler):
20+
fn add(self, method: String, route: String, handler: HTTPHandlerType):
2121
self.routes[method + ":" + route] = handler
2222

2323
fn call(self, context: Context) -> HTTPResponse:

lightbug_http/middleware/static.mojo

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct StaticMiddleware(Middleware):
99
fn set_next(self, next: Middleware):
1010
self.next = next
1111

12-
fn __init__(self, path: String):
12+
fn __init__(inout self, path: String):
1313
self.path = path
1414

1515
fn call(self, context: Context) -> HTTPResponse:
@@ -19,7 +19,7 @@ struct StaticMiddleware(Middleware):
1919

2020
try:
2121
var html: String
22-
with open(file, "r") as f:
22+
with open(path, "r") as f:
2323
html = f.read()
2424

2525
return Success(html, "text/html")

0 commit comments

Comments
 (0)