From a53e6bdf54060e6a851a59e854a5fcb6fa36a847 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Tue, 8 Apr 2025 14:42:56 +0800 Subject: [PATCH] refactor: remove key verification controller and update routes - Deleted KeyVerificationController to simplify the application - Adjusted order of endpoints in SubmitToIndexnowWorker - Removed key verification route that was previously handled by the controller - Added new static text file for key verification instead This change streamlines the key verification process by removing unnecessary code and implementing a simpler method using a text file. --- app/controllers/key_verification_controller.rb | 10 ---------- app/workers/submit_to_indexnow_worker.rb | 4 ++-- config/routes.rb | 3 --- public/339ecd3e9cf648c29b767f5673329e48.txt | 1 + 4 files changed, 3 insertions(+), 15 deletions(-) delete mode 100644 app/controllers/key_verification_controller.rb create mode 100644 public/339ecd3e9cf648c29b767f5673329e48.txt diff --git a/app/controllers/key_verification_controller.rb b/app/controllers/key_verification_controller.rb deleted file mode 100644 index 350294c..0000000 --- a/app/controllers/key_verification_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -# app/controllers/key_verification_controller.rb -class KeyVerificationController < ApplicationController - def show - if params[:id] == "339ecd3e9cf648c29b767f5673329e48" - render plain: "339ecd3e9cf648c29b767f5673329e48" - else - render status: :not_found, plain: "Not Found" - end - end -end diff --git a/app/workers/submit_to_indexnow_worker.rb b/app/workers/submit_to_indexnow_worker.rb index 090edb3..6e604a8 100644 --- a/app/workers/submit_to_indexnow_worker.rb +++ b/app/workers/submit_to_indexnow_worker.rb @@ -10,8 +10,8 @@ class SubmitToIndexnowWorker INDEXNOW_KEY = "339ecd3e9cf648c29b767f5673329e48" INDEXNOW_ENDPOINTS = [ - "https://api.indexnow.org/indexnow", - "https://www.bing.com/indexnow" + "https://www.bing.com/indexnow", + "https://api.indexnow.org/indexnow" ] def perform(recent = true) diff --git a/config/routes.rb b/config/routes.rb index 8430af4..1812cba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,9 +44,6 @@ Rails.application.routes.draw do # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check - # IndexNow key验证 - get "/:id.txt", to: "key_verification#show", constraints: { id: /\w{32}/ } - # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker diff --git a/public/339ecd3e9cf648c29b767f5673329e48.txt b/public/339ecd3e9cf648c29b767f5673329e48.txt new file mode 100644 index 0000000..4587c3a --- /dev/null +++ b/public/339ecd3e9cf648c29b767f5673329e48.txt @@ -0,0 +1 @@ +339ecd3e9cf648c29b767f5673329e48 \ No newline at end of file