Skip to content

Commit

Permalink
Update hello example to use new service syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 20, 2024
1 parent 3591e9f commit a1147b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
18 changes: 2 additions & 16 deletions examples/hello/config.ru
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
#!/usr/bin/env falcon --verbose serve -c
# frozen_string_literal: true

require 'async'

# Console.logger.debug!

class RequestLogger
def initialize(app)
@app = app
end

def call(env)
@app.call(env)
end
run do |env|
[200, {}, ["Hello World"]]
end

# use RequestLogger

run lambda {|env| [200, {'cache-control' => 'max-age=10, public'}, ["Hello World"]]}
29 changes: 16 additions & 13 deletions examples/hello/falcon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@
# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.

load :rack, :self_signed_tls, :supervisor
require 'falcon/environment/self_signed_tls'
require 'falcon/environment/rack'
require 'falcon/environment/supervisor'

supervisor

rack 'hello.localhost', :self_signed_tls do
# scheme 'http'
# protocol {Async::HTTP::Protocol::HTTP1}
#
# endpoint do
# Async::HTTP::Endpoint.for(scheme, "localhost", port: 9292, protocol: protocol)
# end
service 'hello.localhost' do
include Falcon::Environment::SelfSignedTLS
include Falcon::Environment::Rack

scheme 'http'
protocol {Async::HTTP::Protocol::HTTP1}

endpoint do
Async::HTTP::Endpoint.for(scheme, "localhost", port: 9292, protocol: protocol)
end

append preload "preload.rb"

# Process will connect to supervisor to report statistics periodically, otherwise it would be killed.
# report :supervisor
end

# service 'jobs' do
# shell ['rake', 'background:jobs:process']
# end
service 'supervisor' do
include Falcon::Environment::Supervisor
end

0 comments on commit a1147b8

Please sign in to comment.