summaryrefslogtreecommitdiff
path: root/lib/api/gitignores.rb
blob: 1af9ba6b3163a5b8025b46f666b67875a7dd3c4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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:
    #   key (required) - The key of a license
    #
    # Example Request:
    #   GET /gitignores/elixir
    #
    get 'gitignores/:key' do
      required_attributes! [:key]

      gitignore = Gitlab::Gitignore.find(params[:key])
      not_found!('.gitignore') unless gitignore

      present gitignore, with: Entities::Gitignore
    end
  end
end