module EndpointFlux::Rails::Concerns::EndpointController
Public Instance Methods
endpoint_for(namespace)
click to toggle source
# File lib/endpoint_flux/rails/concerns/endpoint_controller.rb, line 14 def endpoint_for(namespace) return namespace unless ::EndpointFlux.config.endpoints_namespace (::EndpointFlux.config.endpoints_namespace + '/' + namespace).camelize.constantize end
endpoint_params()
click to toggle source
# File lib/endpoint_flux/rails/concerns/endpoint_controller.rb, line 27 def endpoint_params params.permit!.except(:controller, :action, :format).to_h.deep_symbolize_keys end
present(namespace)
click to toggle source
# File lib/endpoint_flux/rails/concerns/endpoint_controller.rb, line 7 def present(namespace) _, response = endpoint_for(namespace).perform(request_object) headers.merge! response.headers render json: response.body end
remote_ip()
click to toggle source
# File lib/endpoint_flux/rails/concerns/endpoint_controller.rb, line 31 def remote_ip ip = request.remote_ip.to_s if ip == '127.0.0.1' ip = request.env['HTTP_X_FORWARDED_FOR'] end ip end
request_object()
click to toggle source
# File lib/endpoint_flux/rails/concerns/endpoint_controller.rb, line 19 def request_object ::EndpointFlux::Request.new( headers: headers.merge('Authorization' => request.headers['authorization']), remote_ip: remote_ip, params: endpoint_params ) end