本文整理匯總了Golang中lib/wcg.Request.URL方法的典型用法代碼示例。如果您正苦於以下問題:Golang Request.URL方法的具體用法?Golang Request.URL怎麽用?Golang Request.URL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lib/wcg.Request
的用法示例。
在下文中一共展示了Request.URL方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetTemplates
func (pi *PageResponse) GetTemplates(req *wcg.Request) []string {
if pi.StatusCode >= 400 {
file := fmt.Sprintf("%d.html", pi.StatusCode)
_, err := os.Stat(path.Join(wcg.ViewConfig.BaseDir, file))
if os.IsNotExist(err) {
return []string{"500.html", "header.html", "footer.html"}
}
return []string{file, "header.html", "footer.html"}
}
// succses case
var _p = pi.templatePath
if _p == "" {
_p = req.URL().Path
}
if strings.HasPrefix(_p, "/") {
_p = fmt.Sprintf(".%s", _p) // make path (/path/to/endpoint/) relative (./path/to/endpoint)
}
if path.Ext(_p) == "" {
_p = path.Join(_p, "/index.html")
}
_, err := os.Stat(path.Join(wcg.ViewConfig.BaseDir, _p))
if os.IsNotExist(err) {
return []string{"default.html", "header.html", "footer.html"}
}
return []string{_p, "header.html", "footer.html"}
}
示例2: IsCron
// IsCronRequest returns true if the request is comming from cron.
func IsCron(req *wcg.Request) bool {
return strings.HasPrefix(req.URL().Path, CronPathPrefix) && req.Header(CronHeader) != ""
}
示例3: IsHook
func IsHook(req *wcg.Request) bool {
return strings.HasPrefix(req.URL().Path, HookPathPrefix)
}
示例4: IsStatic
func IsStatic(req *wcg.Request) bool {
return strings.HasPrefix(req.URL().Path, StaticPathPrefix)
}
示例5: IsAPI
// IsAPIRequest returns true if the request is comming to an API endpoint.
func IsAPI(req *wcg.Request) bool {
return strings.HasPrefix(req.URL().Path, APIPathPrefix)
}