Skip to content

Commit

Permalink
fix: minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
drujensen committed Jun 2, 2024
1 parent c740cd9 commit 04187a0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lightbug_http/middleware/basicauth.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct BasicAuthMiddleware(Middleware):
fn set_next(self, next: Middleware):
self.next = next

fn __init__(self, username: String, password: String):
fn __init__(inout self, username: String, password: String):
self.username = username
self.password = password

Expand Down
2 changes: 1 addition & 1 deletion lightbug_http/middleware/cors.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct CorsMiddleware(Middleware):
fn set_next(self, next: Middleware):
self.next = next

fn __init__(self, allow_origin: String):
fn __init__(inout self, allow_origin: String):
self.allow_origin = allow_origin

fn call(self, context: Context) -> HTTPResponse:
Expand Down
5 changes: 5 additions & 0 deletions lightbug_http/middleware/notfound.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@ from lightbug_http.middleware.helpers import NotFound
## 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
@value
struct NotFoundMiddleware(Middleware):
var next: Middleware

fn set_next(self, next: Middleware):
self.next = next

fn call(self, context: Context) -> HTTPResponse:
return NotFound("Not Found")
2 changes: 1 addition & 1 deletion lightbug_http/middleware/router.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct RouterMiddleware[HTTPHandlerType: HTTPHandler](Middleware):
fn set_next(self, next: Middleware):
self.next = next

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

fn call(self, context: Context) -> HTTPResponse:
Expand Down
4 changes: 2 additions & 2 deletions lightbug_http/middleware/static.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct StaticMiddleware(Middleware):
fn set_next(self, next: Middleware):
self.next = next

fn __init__(self, path: String):
fn __init__(inout self, path: String):
self.path = path

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

try:
var html: String
with open(file, "r") as f:
with open(path, "r") as f:
html = f.read()

return Success(html, "text/html")
Expand Down

0 comments on commit 04187a0

Please sign in to comment.