2015-02-26

Wub Direct example

Tcler's Wiki: Wub Direct


稍微嘗試了一下 Tcler's Wiki 提供的範例,發現 local.tcl 如果是使用 svn checkout 目前的 code,要放在跟 site.config 與 Wub.tcl 同一個目錄中。


我發現在 examples 有放一個 hello-direct.tcl,想要測試這個檔案,所以在 local.tcl 使用:
source examples/hello-direct.tcl

然後加入下列的設定到 site.config -
hello {
       domain Direct
       url /hello
       namespace ::Hello
}

再打 http://localhost:8080/hello/ 測試,是有網頁內容顯示的(而不是丟出錯誤訊息),看起來有成功。


但是在 local.tcl 直接使用 source 的方式感覺還是有點怪怪的,不知是否有更好的方式。


更新:
在設定  hello-direct.tcl 以後,又用 hello 來測試 Wub 的 rewrite 功能,site.config 設定如下:
testrewrite {
    url /testrewrite
    rewrite /hello
}

如果使用 http://localhost:8080/testrewrite/ 測試,確實會被轉到 http://localhost:8080/hello/。

沒有留言: