debian-mirror-gitlab/lib/api/internal/pages.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.6 KiB
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
module API
# Pages Internal API
module Internal
2021-01-03 14:25:43 +05:30
class Pages < ::API::Base
2021-01-29 00:20:46 +05:30
feature_category :pages
2023-01-13 00:05:48 +05:30
urgency :low
2021-01-29 00:20:46 +05:30
2019-12-04 20:38:33 +05:30
before do
authenticate_gitlab_pages_request!
end
helpers do
def authenticate_gitlab_pages_request!
unauthorized! unless Gitlab::Pages.verify_api_request(headers)
end
end
namespace 'internal' do
namespace 'pages' do
2020-04-22 19:07:51 +05:30
desc 'Indicates that pages API is enabled and auth token is valid' do
detail 'This feature was introduced in GitLab 12.10.'
end
get "status" do
no_content!
end
2019-12-21 20:55:43 +05:30
desc 'Get GitLab Pages domain configuration by hostname' do
detail 'This feature was introduced in GitLab 12.3.'
end
params do
requires :host, type: String, desc: 'The host to query for'
end
2019-12-04 20:38:33 +05:30
get "/" do
2023-05-27 22:25:52 +05:30
virtual_domain = ::Gitlab::Pages::VirtualHostFinder.new(params[:host]).execute
2021-02-22 17:27:13 +05:30
no_content! unless virtual_domain
2022-08-13 15:12:31 +05:30
if virtual_domain.cache_key.present?
# Cache context is not added to make it easier to expire the cache with
# Gitlab::Pages::CacheControl
present_cached virtual_domain,
cache_context: nil,
2022-11-25 23:54:43 +05:30
with: Entities::Internal::Pages::VirtualDomain,
expires_in: ::Gitlab::Pages::CacheControl::EXPIRE
2022-08-13 15:12:31 +05:30
else
present virtual_domain, with: Entities::Internal::Pages::VirtualDomain
end
2019-12-04 20:38:33 +05:30
end
end
end
end
end
end