本文整理匯總了Golang中github.com/CJ-Jackson/webby.Web類的典型用法代碼示例。如果您正苦於以下問題:Golang Web類的具體用法?Golang Web怎麽用?Golang Web使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Web類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getCookie
func getCookie(w *webby.Web) *http.Cookie {
cookie, err := w.GetCookie(cookieName)
if err != nil {
cookie = w.NewCookie(cookieName).Value(genKey()).Expires(time.Now().AddDate(0, 1, 0)).SaveRes().SaveReq().Get()
}
return cookie
}
示例2: getCookie
func getCookie(w *webby.Web) *http.Cookie {
cookie, err := w.Cookie(cookieName).Get()
if err != nil {
cookie, _ = w.Cookie(cookieName).Value(webby.KeyGen()).Month().SaveRes().SaveReq().Get()
}
return cookie
}
示例3: IsValidSlot
// For the more complexed form!
func (f *Form) IsValidSlot(w *webby.Web, slot int) bool {
var files FileHeaders
form := w.Form().Slot(slot)
values := Values(form.Value)
files = nil
if form.File != nil {
files = FileHeaders(form.File)
}
return f.isValid(w, values, files)
}
示例4: View
func (ro RouteHandler) View(w *webby.Web) {
truth := ro.Init(w)
if w.CutOut() {
return
}
if !truth {
w.Error403()
return
}
var form *Form
switch t := w.Session.(type) {
case Form:
form = &t
w.DestroySession()
case *Form:
form = t
w.DestroySession()
default:
form = ro.FetchForm(w)
}
if w.Req.Method == "POST" {
goto post
}
if w.Req.URL.RawQuery != "" {
if form.IsValid(w) {
goto pass
} else {
goto get
}
}
get:
ro.Get(w, form)
return
post:
if !form.IsValid(w) {
goto fail
}
pass:
ro.PostPass(w)
return
fail:
w.SetSession(form)
ro.PostFail(w)
}
示例5: IsValid
func (f *Form) IsValid(w *webby.Web) bool {
var values Values
var files FileHeaders
w.ParseForm()
if w.Req.MultipartForm != nil {
values = Values(w.Req.MultipartForm.Value)
files = FileHeaders(w.Req.MultipartForm.File)
} else {
values = Values(w.Req.Form)
files = nil
}
return f.isValid(w, values, files)
}
示例6: Boot
func (_ Check) Boot(w *webby.Web) {
if IncludeGetRequest {
goto parse_form
}
if w.Req.Method == "GET" {
return
}
parse_form:
w.ParseForm()
if w.Req.MultipartForm != nil {
multipartCheck(w)
return
}
formCheck(w)
}
示例7: Validate
func (p Put) Validate(w *webby.Web) {
var data struct {
Pass bool `json:"pass"`
Url string `json:"url"`
Html string `json:"html"`
}
data.Pass = true
data.Url = p.url
if !p.form.IsValid(w) {
data.Pass = false
data.Html = p.form.Render()
if p.failFunc != nil {
p.failFunc(w)
}
} else {
if p.passFunc != nil {
p.passFunc(w)
}
}
w.Json().Send(data)
}
示例8: formCheck
func formCheck(w *webby.Web) {
form := w.Form()
if len(form.Value) <= 0 {
return
}
if len(form.Value[cookieName]) <= 0 {
w.Error403()
return
}
if form.Value[cookieName][0] != getCookie(w).Value {
w.Error403()
return
}
}
示例10: View
func (rss RssRouteHandler) View(w *webby.Web) {
w.InitCompression()
w.Print(rss.Feed(w).RSS())
}
示例11: LoggerStd
func LoggerStd(w *webby.Web) string {
return fmt.Sprintf("%s %s %s %s ?%s IP:%s %v", w.Req.Proto, w.Req.Method,
w.Req.Host, w.Req.URL.Path,
w.Req.URL.RawQuery, w.RemoteAddr(), time.Now())
}