archive/util.go

38 lines
666 B
Go
Raw Normal View History

2017-08-13 02:41:14 +00:00
package archive
2017-08-13 03:51:32 +00:00
import (
"fmt"
"net/http"
"strconv"
)
2017-08-13 02:41:14 +00:00
func attr(condition bool, whenMet string) string {
if condition {
return whenMet
} else {
return ""
}
}
2017-08-13 03:51:32 +00:00
type URLHelper struct {
w http.ResponseWriter
r *http.Request
}
func (this *URLHelper) intval(sz string) int {
ret, _ := strconv.Atoi(sz)
return ret
}
func (this *URLHelper) get(sz string) string {
return this.r.URL.Query().Get(sz)
}
func (this *URLHelper) hasGet(sz string) bool {
return len(this.r.URL.Query().Get(sz)) > 0
}
func (this *URLHelper) redirectf(format string, a ...interface{}) {
http.Redirect(this.w, this.r, fmt.Sprintf(format, a...), http.StatusTemporaryRedirect)
}