summaryrefslogtreecommitdiff
path: root/lib/api/gitignores.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/gitignores.rb')
-rw-r--r--lib/api/gitignores.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/api/gitignores.rb b/lib/api/gitignores.rb
new file mode 100644
index 00000000000..270c9501dd2
--- /dev/null
+++ b/lib/api/gitignores.rb
@@ -0,0 +1,29 @@
+module API
+ class Gitignores < Grape::API
+
+ # Get the list of the available gitignore templates
+ #
+ # Example Request:
+ # GET /gitignores
+ get 'gitignores' do
+ present Gitlab::Gitignore.all, with: Entities::GitignoresList
+ end
+
+ # Get the text for a specific gitignore
+ #
+ # Parameters:
+ # name (required) - The name of a license
+ #
+ # Example Request:
+ # GET /gitignores/Elixir
+ #
+ get 'gitignores/:name' do
+ required_attributes! [:name]
+
+ gitignore = Gitlab::Gitignore.find(params[:name])
+ not_found!('.gitignore') unless gitignore
+
+ present gitignore, with: Entities::Gitignore
+ end
+ end
+end