404状态码测试页面

This commit is contained in:
xxq250 2023-08-30 09:13:05 +08:00
parent 67f3a87afc
commit 6bc0587168
1 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,17 @@ class MainController < ApplicationController
render :json => { status: 0, message: Time.now.to_i } render :json => { status: 0, message: Time.now.to_i }
end end
def test_404
status_code = 404
status = status_code.to_s
fname = %w[404 403 422 500].include?(status) ? status : "unknown"
respond_to do |format|
format.html { render template: "/shared/#{fname}", handler: [:erb], status: status }
format.all { render body: nil, status: status }
end
end
def index def index
domain_session = params[:_educoder_session] domain_session = params[:_educoder_session]
if domain_session if domain_session
@ -24,6 +35,8 @@ class MainController < ApplicationController
# TODO: 这块之后需要整合者架构重新变化统一跳转到index后再路由分发 # TODO: 这块之后需要整合者架构重新变化统一跳转到index后再路由分发
if params[:path] && params[:path]&.include?("h5educoderbuild") && params[:path].split("/").first == "h5educoderbuild" if params[:path] && params[:path]&.include?("h5educoderbuild") && params[:path].split("/").first == "h5educoderbuild"
render file: 'public/h5educoderbuild/index.html', :layout => false, :content_type=> 'text/html' render file: 'public/h5educoderbuild/index.html', :layout => false, :content_type=> 'text/html'
elsif params[:path].to_s.include?("test_404")
test_404
else else
render file: 'public/react/build/index.html', :layout => false, :content_type=> 'text/html' render file: 'public/react/build/index.html', :layout => false, :content_type=> 'text/html'
end end