Yessiest
8 months ago
9 changed files with 154 additions and 64 deletions
-
119README.md
-
22examples/buckets.ru
-
13examples/helloworld.ru
-
1examples/lib
-
25examples/logging.ru
-
20examples/stack.ru
-
12examples/staticfiles.ru
-
1lib/hyde/probe/handler.rb
-
5lib/hyde/request.rb
@ -0,0 +1,22 @@ |
|||
# frozen_string_literal: true |
|||
|
|||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") |
|||
require 'hyde' |
|||
|
|||
stack = { "1" => [], "2" => [], "3" => [] } |
|||
|
|||
app = Hyde::Server.new do |
|||
path "bucket_(1|2|3)" do |
|||
get "pop" do |bucket| |
|||
header "content-type", "text/plain" |
|||
stack[bucket].pop.to_s |
|||
end |
|||
post "push" do |bucket| |
|||
header "content-type", "text/plain" |
|||
stack[bucket].push(request.body) |
|||
request.body |
|||
end |
|||
end |
|||
end |
|||
|
|||
run app |
@ -0,0 +1,13 @@ |
|||
# frozen_string_literal: true |
|||
|
|||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") |
|||
require 'hyde' |
|||
|
|||
app = Hyde::Server.new do |
|||
get "/hello" do |
|||
header "content-type", "text/plain" |
|||
"Hello World!" |
|||
end |
|||
end |
|||
|
|||
run app |
@ -0,0 +1 @@ |
|||
../lib |
@ -0,0 +1,25 @@ |
|||
# frozen_string_literal: true |
|||
|
|||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") |
|||
require 'hyde' |
|||
|
|||
app = Hyde::Server.new do |
|||
path "unimportant" do |
|||
get "version" do |
|||
header "content-type", "text/plain" |
|||
"1337 (the best one)" |
|||
end |
|||
end |
|||
path "important" do |
|||
preprocess do |req| |
|||
# Implement logging logic here |
|||
puts "Client at #{req.headers['REMOTE_ADDR']} wanted to access something /important!" |
|||
end |
|||
get "answer" do |
|||
header "content-type", "application/json" |
|||
'{"answer":42, "desc":"something important!"}' |
|||
end |
|||
end |
|||
end |
|||
|
|||
run app |
@ -0,0 +1,20 @@ |
|||
# frozen_string_literal: true |
|||
|
|||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") |
|||
require 'hyde' |
|||
|
|||
stack = [] |
|||
|
|||
app = Hyde::Server.new do |
|||
get "/pop" do |
|||
header 'content-type', 'text/plain' |
|||
stack.pop.to_s |
|||
end |
|||
post "/push" do |
|||
header 'content-type', 'text/plain' |
|||
stack.push(request.body) |
|||
request.body |
|||
end |
|||
end |
|||
|
|||
run app |
@ -0,0 +1,12 @@ |
|||
# frozen_string_literal: true |
|||
|
|||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") |
|||
require 'hyde' |
|||
|
|||
app = Hyde::Server.new do |
|||
root "/var/www" |
|||
index ["index.html", "index.htm"] |
|||
serve "**/*.(html|htm)" |
|||
end |
|||
|
|||
run app |
Write
Preview
Loading…
Cancel
Save
Reference in new issue