[Step1|BE] Implement snippet blob raw action
Important: All the new functionality must be implemented behind the feature flag :snippet_multiple_files
. Besides, it has to be scoped for users. Therefore, instead of checking if the feature flag is enabled or not (Feature.enabled?(:snippet_multiple_files)
), we will check if the feature flag is enabled for specific users (Feature.enabled?(:snippet_multiple_files, user)
).
At the moment, we can access the snippet raw content by accessing https://gitlab.com/snippets/1234/raw
. Nevertheless, this is no longer going to be true once we have multiple files. The new URL will have to be something like https://gitlab.com/snippets/1234/raw/revision/snippet_file_path
.
The behavior is very similar to the Projects::RawController
. We will need to create a new controller for snippet blobs, add the raw route (than can be handled by the show
action). We can opt for different approaches here, we can follow what projects do and create a
RawControlleror create a
Snippets::BlobsController` that gather all the necessary logic for snippet blobs.
The new raw route in snippets will have a ref or revision and then the file path of the blob that we want to see the raw content.
When the feature flag is disabled, the new routes will return a 404.
For the old and currently existing raw route (without revision and path), I'd keep it and just return the raw content of the first blob we can find in the repository when the feature flag is enabled.