Class: ApiController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ApiController
- Defined in:
- app/controllers/api_controller.rb
Instance Method Summary collapse
Instance Method Details
#empty_json ⇒ Object
17 18 19 |
# File 'app/controllers/api_controller.rb', line 17 def empty_json render json: [] end |
#file_preview ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/api_controller.rb', line 6 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 |
#regexp_preview ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/api_controller.rb', line 21 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.}" } end |