Last active
August 29, 2015 14:10
-
-
Save marcy-terui/05b9ea5a6ac2b023fce3 to your computer and use it in GitHub Desktop.
ISUCON4予選問題をngx_mrubyだけで解いてみた(ノウハウ編) ref: http://qiita.com/Marcy/items/1a7ab35970c31d169bf8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r = Nginx::Request.new | |
Nginx.echo r.args #=> "id=hoge&name=fuga" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r = Nginx::Request.new | |
Nginx.echo r.var.request_body #=> "login=hoge&password=fuga" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r = Nginx::Request.new | |
Nginx.echo r.var.http_cookie #=> "login=hoge&password=fuga" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
year = Time.now.year - 1 | |
r = Nginx::Request.new | |
r.headers_out['Set-Cookie'] = "notice=+; expires=Mon, 25-Nov-#{year} 11:11:11 GMT; path=/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p Time.now.strftime("%Y-%m-%d %H:%M:%S") #=> "2014-12-05 00:11:22" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
year = Time.now.year | |
month = Time.now.month | |
day = Time.now.day | |
hour = Time.now.hour | |
min = Time.now.min | |
sec = Time.now.sec | |
month = month < 10 ? "0#{month.to_s}" : month.to_s | |
day = day < 10 ? "0#{day.to_s}" : day.to_s | |
hour = hour < 10 ? "0#{hour.to_s}" : hour.to_s | |
min = min < 10 ? "0#{min.to_s}" : min.to_s | |
sec = sec < 10 ? "0#{sec.to_s}" : sec.to_s | |
Nginx.echo "#{year}-#{month}-#{day} #{hour}:#{min}:#{sec}" #=> "2014-12-05 00:11:22" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r = Nginx::Request.new | |
r.headers_out["Location"] = "http://#{r.var.http_host}/mypage" | |
Nginx.return Nginx::HTTP_MOVED_TEMPORARILY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v = Nginx::Var.new | |
v.arg_name #=> "matsumotory" | |
v.arg_id #=> 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set_form_input $login; | |
set_form_input $password; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment