本文整理汇总了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())
}