Class: MainController
Constant Summary
collapse
- AUTH_IMG_EXT =
%w(.jpg .jpeg .png .gif)
Instance Attribute Summary
#callpath, #cookies, #extension, #params, #req
Instance Method Summary
collapse
after_action, before_action, #execute_after_action, #execute_before_action, #html?, #initialize, #json?, #log, parse_action_opts, #plain?, #url_for
Instance Method Details
#add_cookie ⇒ Object
70
71
72
73
|
# File 'app/main.rb', line 70
def add_cookie
cookies["UN_COOKIE_VAUT:"] = "UN BON MOMENT !"
{plain: "cookie set"}
end
|
#add_url ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'app/main.rb', line 33
def add_url
url = params["url"]
if url
Dataset << url
return {plain: "#{url} added"}
else
return {plain: "url argument required"}
end
end
|
#debug ⇒ Object
79
80
81
82
83
|
# File 'app/main.rb', line 79
def debug
{}
end
|
#err500 ⇒ Object
90
91
92
|
# File 'app/main.rb', line 90
def err500
tessssssssss
end
|
#fct_after_root ⇒ Object
15
16
17
|
# File 'app/main.rb', line 15
def fct_after_root
end
|
#fct_before_all ⇒ Object
7
8
9
|
# File 'app/main.rb', line 7
def fct_before_all
end
|
#fct_before_root ⇒ Object
11
12
13
|
# File 'app/main.rb', line 11
def fct_before_root
end
|
#get_cookies ⇒ Object
75
76
77
|
# File 'app/main.rb', line 75
def get_cookies
{json: cookies.to_h}
end
|
#hello ⇒ Object
53
54
55
|
# File 'app/main.rb', line 53
def hello
{html: "<html><body><h1>hello world</h1><p>lol</p></body></html>"}
end
|
#image ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/main.rb', line 58
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
|
#log_param_x ⇒ Object
85
86
87
88
|
# File 'app/main.rb', line 85
def log_param_x
Logger.fd = File.open '/tmp/nephos_ftest.log', 'w'
log "#{params[:x]}"
end
|
#rm_url ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'app/main.rb', line 43
def rm_url
url = params[:url]
if url
Dataset.rm url
return {plain: "#{url} removed"}
else
return {plain: "url argument required"}
end
end
|
#root ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/main.rb', line 19
def root
cookies["a"] = "b"
cookies.delete("b").to_h
{
json: {
list: $dataset,
add: '/add',
rm: '/rm',
}
}
end
|