Sha256: f7ae438a6458bdee3796c72cf642200c74b0238d363050b9c8341db043ef0e54
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
class ApiController < ApplicationController def tree render json: Treeview.tree(params[:path]) end def file_preview file = params[:file] unless File.exists?(file) return render json: [], status: 404 end unless File.file?(file) && File.readable?(file) return render json: [], status: 403 end render json: file_tail(file) end def empty_json render json: [] end def regexp_preview plugin_config = prepare_plugin_config || {} preview = RegexpPreview.processor(params[:parse_type]).new(params[:file], params[:parse_type], plugin_config) render json: preview.matches rescue Fluent::ConfigError => ex render json: { error: "#{ex.class}: #{ex.message}" } end private def prepare_plugin_config plugin_config = params[:plugin_config] case params[:parse_type] when "multiline" plugin_config[:formats].lines.each.with_index do |line, index| plugin_config["format#{index + 1}"] = line.chomp end plugin_config else plugin_config end end end
Version data entries
4 entries across 4 versions & 1 rubygems