diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-26 21:51:24 +0300 |
---|---|---|
committer | Jacob Schatz <jschatz1@gmail.com> | 2017-06-14 04:33:26 +0300 |
commit | d9b15661c97c471a1fa880a84fb6f1d6d4a2a2a5 (patch) | |
tree | 9af3da7b47fcc89e1f369a506403fd9763c0c024 /app/controllers/projects/tree_controller.rb | |
parent | 0037cf634dbcc8045fba9cbc28133cfde07dc97c (diff) |
Add experimental JSON format for tree controller
Diffstat (limited to 'app/controllers/projects/tree_controller.rb')
-rw-r--r-- | app/controllers/projects/tree_controller.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index 266a15c1cf9..98f3a72e3c1 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -24,12 +24,19 @@ class Projects::TreeController < Projects::ApplicationController end end - @last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit - respond_to do |format| - format.html - # Disable cache so browser history works - format.js { no_cache_headers } + format.html do + @last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit + end + + format.js do + # Disable cache so browser history works + no_cache_headers + end + + format.json do + render json: TreeSerializer.new(project: @project, repository: @repository, ref: @ref).represent(@tree) + end end end |