Sha256: 2ee02e8992c1f33d62530c4e925a65b5f5458a9ddb99998adaa335d72bd157b6
Contents?: true
Size: 1.6 KB
Versions: 7
Compression:
Stored size: 1.6 KB
Contents
#!/usr/bin/env ruby # This is the AutoResponse rule config file # using ruby syntax # Examples: # if you want to respond all requests with url # equals "http://www.1688.com" with "Hello world!" : url "http://www.1688.com" r "Hello world" # or you can respond with Array url "http://china.alibaba.com" r [200, {}, "Got replaced"] #[status, header, body] # if you want to respond these requests with a file: url "http://www.yousite.com" goto "/home/youruser/somefile.txt" # on Windows: url "http://www.another-site.com" goto "C:/Program\ Files/proj/test.txt" # if you want to respond with another remote url: url "http://www.targetsite.com" goto "http://www.real-request-target.com/test.html" # you can set response headers in the returned string # e.g. url "http://www.target-site.com/target-url" r <<-RESP Test-Msg : http-header-example header-server : Auto-Responder Content-Type : text/html; charset=utf-8 <!Doctype html> <html><body><h1>Hello world!</h1></body></html> RESP # just respond with status number url "http://www.catchme.com" r 404 # Example of using regexp url %r{http://pnq\.cc} r "Any request made to pnq.cc will be responded with this message." # Regular expression and params url %r{http://anysite\.cc(.*)} do |uri, path| <<-RESP Content-Type : text/html; charset=utf-8 <style> body { font-size: 50pt; } em { color: #ff7300; } small { color: #ccc; } </style> With regular expression, you can do more powerful things. <br/> You're requesting <em>#{path}</em> <br/> <small>Server time is #{Time.now} now. </small> RESP end
Version data entries
7 entries across 7 versions & 1 rubygems