Yessiest
8 months ago
8 changed files with 95 additions and 45 deletions
-
7examples/form/form.ru
-
3examples/logging.ru
-
28lib/hyde/dsl/common_methods.rb
-
47lib/hyde/dsl/probe_methods.rb
-
22lib/hyde/path.rb
-
6lib/hyde/probe/binding.rb
-
16lib/hyde/util/html.rb
-
11lib/hyde/util/query.rb
@ -0,0 +1,28 @@ |
|||
# frozen_string_literal: true |
|||
|
|||
module Hyde |
|||
module DSL |
|||
# Methods shared by probes, preprocessors and filters. |
|||
module CommonMethods |
|||
# Stop execution and generate a boilerplate response with the given code |
|||
# @param errorcode [Integer] |
|||
# @param backtrace [Array(String), nil] |
|||
# @raise [UncaughtThrowError] throws :finish to return back to Server |
|||
def die(errorcode, backtrace: nil) |
|||
throw :finish, [errorcode].append( |
|||
*(@origin.properties["handle.#{errorcode}"] or |
|||
@origin.properties["handle.default"]).call( |
|||
errorcode, |
|||
backtrace: backtrace |
|||
) |
|||
) |
|||
end |
|||
|
|||
# Bounce request to the next handler |
|||
# @raise [UncaughtThrowError] throws :break to get out of the callback |
|||
def bounce |
|||
throw :break |
|||
end |
|||
end |
|||
end |
|||
end |
@ -1,12 +1,16 @@ |
|||
# frozen_string_literal: true |
|||
|
|||
require_relative "../dsl/probe_methods" |
|||
require_relative "../dsl/common_methods" |
|||
|
|||
module Hyde |
|||
# Binding that provides execution context for Probes. |
|||
class ProbeBinding |
|||
include Hyde::DSL::ProbeMethods |
|||
include Hyde::DSL::CommonMethods |
|||
|
|||
def initialize(origin) |
|||
@origin = origin |
|||
end |
|||
include Hyde::DSL::ProbeMethods |
|||
end |
|||
end |
Write
Preview
Loading…
Cancel
Save
Reference in new issue