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.
This commit is contained in:
songtianlun 2025-04-08 14:42:56 +08:00
parent 67e15e1fee
commit a53e6bdf54
4 changed files with 3 additions and 15 deletions

View File

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

View File

@ -10,8 +10,8 @@ class SubmitToIndexnowWorker
INDEXNOW_KEY = "339ecd3e9cf648c29b767f5673329e48" INDEXNOW_KEY = "339ecd3e9cf648c29b767f5673329e48"
INDEXNOW_ENDPOINTS = [ 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) def perform(recent = true)

View File

@ -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. # 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 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) # 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 "manifest" => "rails/pwa#manifest", as: :pwa_manifest
# get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker

View File

@ -0,0 +1 @@
339ecd3e9cf648c29b767f5673329e48