This commit is contained in:
BoHung Chiu 2023-04-21 00:11:21 +08:00
parent 1a2618319a
commit 41edf2108c
3 changed files with 32 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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"