Created
July 26, 2026 09:13
-
-
Save mostlyobvious/1e21c39b87c0a33ff8b933a7ceff79b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile do | |
| source "https://rubygems.org" | |
| gem "rails", "7.1.3.2" | |
| end | |
| require "action_controller/railtie" | |
| require "rackup" | |
| module KakaDudu | |
| class Reverse | |
| def initialize(app) = @app = app | |
| def call(env) | |
| status, headers, response = @app.call(env) | |
| [status, headers, [response.body.reverse]] | |
| end | |
| end | |
| class Application < Rails::Application | |
| config.consider_all_requests_local = true | |
| config.eager_load = false | |
| config.load_defaults "7.1" | |
| config.root = __dir__ | |
| config.secret_key_base = "dupa.8" | |
| routes.append do | |
| get "/original", to: "kaka_dudu/self#original" | |
| # get "/remake", to: Reverse.new(KakaDudu::SelfController.action(:remake)) | |
| get "/remake", to: "kaka_dudu/self#remake" | |
| end | |
| end | |
| class SelfController < ActionController::Base | |
| def original = render plain: "kaka dudu" | |
| def remake = render plain: "dudu kaka" | |
| end | |
| end | |
| KakaDudu::Application.initialize! | |
| app = | |
| Rack::Builder.new do | |
| run do |env| | |
| app_ = | |
| if env["PATH_INFO"] == "/reverse" | |
| KakaDudu::Reverse.new(KakaDudu::Application) | |
| else | |
| KakaDudu::Application | |
| end | |
| app_.call(env) | |
| end | |
| end | |
| Rackup::Server.start(app: app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment