Sha256: 0ac3d7b79fbd42764a8d363771d08180bf9478a3dcfcdb22f1d5d685f8f689a5
Contents?: true
Size: 1.79 KB
Versions: 3
Compression:
Stored size: 1.79 KB
Contents
class MainController < Nephos::Controller before_action :fct_before_all before_action :fct_before_root, only: [:root] after_action :fct_after_root, only: :root def fct_before_all # puts "BEFORE ALL" end def fct_before_root # puts "BEFORE" end def fct_after_root # puts "AFTER" end def root # puts "ROOT" cookies["a"] = "b" cookies.delete("b").to_h # puts "Cookies from the root:", cookies { json: { list: $dataset, add: '/add', rm: '/rm', } } end def add_url url = params["url"] if url Dataset << url return {plain: "#{url} added"} else return {plain: "url argument required"} end end def rm_url url = params[:url] if url Dataset.rm url return {plain: "#{url} removed"} else return {plain: "url argument required"} end end def hello {html: "<html><body><h1>hello world</h1><p>lol</p></body></html>"} end AUTH_IMG_EXT = %w(.jpg .jpeg .png .gif) def image dir = File.expand_path('app/') file = File.expand_path(params["image"], dir) if not file[0..(dir.size-1)] == dir or not AUTH_IMG_EXT.include?(File.extname(file)) return {status: 500, content: "invalid path #{params['image']}"} elsif not File.exist? file return {status: 404, content: "invalid path #{params['image']}"} else return {type: 'image/jpeg', content: File.read(file)} end end def add_cookie cookies["UN_COOKIE_VAUT:"] = "UN BON MOMENT !" {plain: "cookie set"} end def get_cookies {json: cookies.to_h} end def debug #require 'pry' #binding.pry {} end def log_param_x Logger.fd = File.open '/tmp/nephos_ftest.log', 'w' log "#{params[:x]}" end def err500 tessssssssss end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nephos-server-0.7.2 | app/main.rb |
nephos-server-0.7.1 | app/main.rb |
nephos-server-0.7.0 | app/main.rb |