2012年11月30日 星期五

Stingray Rule的http操作

http這個物件在Stingray中有許多有用的操作,這邊列出幾個常用的:

  • http.getRawURL(); 取出使用者連到LB的網址,值的部份不包含IP、PORT與協定,僅從Context開始之後 ex:/Wiki/en/somepage.jsp
  • http.getMethod(); 取出連線時候的http method,可以作為判斷RESTful操作方法之使用 ex: GET or POST
  • http.getBody(); 取回連線時候送進LB的內文,一般用在Request Rule中 ex: {"title":"hello","content":"test 123"}
  • http.getResponseBody(); 取回使用者要求之回應內容,一般用在Response Rule中 ex: <html>....</html>