Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boolean flag skip_router to Context #69

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/grip/application.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Grip
getter scopes : Array(String) = [] of String
getter valves : Array(Symbol) = [] of Symbol
getter valve : Symbol?

property router : Array(HTTP::Handler)

def initialize(@environment : String = "development")
Expand Down
2 changes: 2 additions & 0 deletions src/grip/extensions/context.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Grip
module Context
property exception : Exception?
property parameters : Grip::Parsers::ParameterBox?
property? skip_router : Bool = false

# Deletes request header.
def delete_req_header(key)
Expand Down Expand Up @@ -156,6 +157,7 @@ module Grip

def exec
with self yield
self
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/grip/routers/http.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Grip
end

def call(context : HTTP::Server::Context)
return context if context.response.closed?
return context if context.skip_router? || context.response.closed?

route = find_route(context.request.method.as(String), context.request.path)
route = find_route("ALL", context.request.path) unless route.found?
Expand Down
2 changes: 2 additions & 0 deletions src/grip/routers/websocket.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module Grip
end

def call(context : HTTP::Server::Context)
return context if context.skip_router? || context.response.closed?

route = find_route("", context.request.path)

unless route.found? && websocket_upgrade_request?(context)
Expand Down
Loading