diff options
Diffstat (limited to 'app/helpers/workhorse_helper.rb')
-rw-r--r-- | app/helpers/workhorse_helper.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/helpers/workhorse_helper.rb b/app/helpers/workhorse_helper.rb new file mode 100644 index 00000000000..2bd0dbfd095 --- /dev/null +++ b/app/helpers/workhorse_helper.rb @@ -0,0 +1,24 @@ +# Helpers to send Git blobs, diffs or archives through Workhorse. +# Workhorse will also serve files when using `send_file`. +module WorkhorseHelper + # Send a Git blob through Workhorse + def send_git_blob(repository, blob) + headers.store(*Gitlab::Workhorse.send_git_blob(repository, blob)) + headers['Content-Disposition'] = 'inline' + headers['Content-Type'] = safe_content_type(blob) + head :ok # 'render nothing: true' messes up the Content-Type + end + + # Send a Git diff through Workhorse + def send_git_diff(repository, diff_refs) + headers.store(*Gitlab::Workhorse.send_git_diff(repository, diff_refs)) + headers['Content-Disposition'] = 'inline' + head :ok + end + + # Archive a Git repository and send it through Workhorse + def send_git_archive(repository, ref:, format:) + headers.store(*Gitlab::Workhorse.send_git_archive(repository, ref: ref, format: format)) + head :ok + end +end |