diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-09-01 16:34:31 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-09-01 16:34:31 +0100 |
commit | 054b3a500c1eb9f3b2a24f056688934ac30a1caa (patch) | |
tree | 1abeac650ad396f854aa97c4da0f275e50772180 /lib/api/files.rb | |
parent | 4d313c3b2e3824422d24860a082daab57ba5bcb6 (diff) | |
parent | ad32bac56de11aa75a41f4e88f28632c5ca0ff70 (diff) | |
download | gitlab-ce-054b3a500c1eb9f3b2a24f056688934ac30a1caa.tar.gz |
Merge branch 'master' into vue-docs
* master: (215 commits)
Simplify Git interactions in AfterImportService
Remove some empty lines from notify specs
Validate unescaped `%` chars in PO files
Optimize notification emails specs
Fixed group merge requests failure
Rollsback changes made to signing_enabled.
Changed title on 404 page
Changed message and title on the 404 page
Make Gitaly PostUploadPack mandatory
Use gitaly 0.36.0
Instrument MergeRequest#fetch_ref
/move project functionality. Squash commit.
Remove closing external issues by reference error
Fetch all translation keys using a regex
Take `nplurals` into account when validating translations.
Check for newlines in different methods on TranslationEntry
Split translation & metadata entries into classes
Validate the number of plurals in an entry
Move detailed information of an entry into a separate class
Move `PoLinter` into `Gitlab::I18n`
...
Diffstat (limited to 'lib/api/files.rb')
-rw-r--r-- | lib/api/files.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/api/files.rb b/lib/api/files.rb index e2ac7142bc4..1598d3c00b8 100644 --- a/lib/api/files.rb +++ b/lib/api/files.rb @@ -1,5 +1,7 @@ module API class Files < Grape::API + FILE_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(file_path: API::NO_SLASH_URL_PART_REGEX) + # Prevents returning plain/text responses for files with .txt extension after_validation { content_type "application/json" } @@ -58,13 +60,13 @@ module API params do requires :id, type: String, desc: 'The project ID' end - resource :projects, requirements: { id: %r{[^/]+} } do + resource :projects, requirements: FILE_ENDPOINT_REQUIREMENTS do desc 'Get raw file contents from the repository' params do requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb' requires :ref, type: String, desc: 'The name of branch, tag commit' end - get ":id/repository/files/:file_path/raw" do + get ":id/repository/files/:file_path/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do assign_file_vars! send_git_blob @repo, @blob @@ -75,7 +77,7 @@ module API requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb' requires :ref, type: String, desc: 'The name of branch, tag or commit' end - get ":id/repository/files/:file_path", requirements: { file_path: /.+/ } do + get ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do assign_file_vars! { @@ -95,7 +97,7 @@ module API params do use :extended_file_params end - post ":id/repository/files/:file_path", requirements: { file_path: /.+/ } do + post ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do authorize! :push_code, user_project file_params = declared_params(include_missing: false) @@ -113,7 +115,7 @@ module API params do use :extended_file_params end - put ":id/repository/files/:file_path", requirements: { file_path: /.+/ } do + put ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do authorize! :push_code, user_project file_params = declared_params(include_missing: false) @@ -137,7 +139,7 @@ module API params do use :simple_file_params end - delete ":id/repository/files/:file_path", requirements: { file_path: /.+/ } do + delete ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do authorize! :push_code, user_project file_params = declared_params(include_missing: false) |