summaryrefslogtreecommitdiff
path: root/lib/api/gitignores.rb
blob: 270c9501dd2271b3f58e834b56145feeea9dab12 (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:
    #   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