From 41edf2108cf70177d0aa888b3c95b91af69db1d6 Mon Sep 17 00:00:00 2001 From: bohung Date: Fri, 21 Apr 2023 00:11:21 +0800 Subject: [PATCH] add plow --- app/controllers/admin/plow_controller.rb | 29 ++++++++++++++++++++++++ client_management.gemspec | 1 + config/routes.rb | 2 ++ 3 files changed, 32 insertions(+) create mode 100644 app/controllers/admin/plow_controller.rb diff --git a/app/controllers/admin/plow_controller.rb b/app/controllers/admin/plow_controller.rb new file mode 100644 index 0000000..dbbb6ae --- /dev/null +++ b/app/controllers/admin/plow_controller.rb @@ -0,0 +1,29 @@ +class Admin::PlowController < ApplicationController + include ReverseProxy::Controller + + def index + # Assuming the WordPress server is being hosted on port 8080 + reverse_proxy "unix://#{Rails.root}/tmp/plow.sock", path: '/' do |config| + # We got a 404! + # config.on_missing do |code, response| + # redirect_to root_url and return + # end + + # There's also other callbacks: + # - on_set_cookies + # - on_connect + # - on_response + # - on_set_cookies + # - on_success + # - on_redirect + # - on_missing + # - on_error + # - on_complete + end + end + def show + path = request.env['ORIGINAL_FULLPATH'] + reverse_proxy "unix://#{Rails.root}/tmp/plow.sock", path: '/' do |config| + end + end +end \ No newline at end of file diff --git a/client_management.gemspec b/client_management.gemspec index 5664770..e11a222 100644 --- a/client_management.gemspec +++ b/client_management.gemspec @@ -14,6 +14,7 @@ Gem::Specification.new do |s| s.description = "ClientManagement tool for store." s.license = "MIT" s.add_dependency "net-ssh", ">= 4.0", "< 5.0" + s.add_dependency "rails-reverse-proxy" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.test_files = Dir["test/**/*"] end diff --git a/config/routes.rb b/config/routes.rb index e8a23cc..b407e5e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,8 @@ Rails.application.routes.draw do # get "client_managements/completed_requests", to: 'client_managements#completed_requests' # get "client_managements/contracts", to: 'client_managements#contracts' + match 'plow' => 'plow#index', via: [:get, :post, :put, :patch, :delete] + match 'plow/*path' => 'plow#show', via: [:get, :post, :put, :patch, :delete] resources :client_managements do member do get "make_contract"