本文整理匯總了Golang中github.com/pierrre/imageserver.Params.GetBool方法的典型用法代碼示例。如果您正苦於以下問題:Golang Params.GetBool方法的具體用法?Golang Params.GetBool怎麽用?Golang Params.GetBool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pierrre/imageserver.Params
的用法示例。
在下文中一共展示了Params.GetBool方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: buildArgumentsMonochrome
func (server *Server) buildArgumentsMonochrome(arguments *list.List, params imageserver.Params) error {
monochrome, _ := params.GetBool("monochrome")
if monochrome {
arguments.PushBack("-monochrome")
}
return nil
}
示例2: buildArgumentsFlop
func (server *Server) buildArgumentsFlop(arguments *list.List, params imageserver.Params) error {
flop, _ := params.GetBool("flop")
if flop {
arguments.PushBack("-flop")
}
return nil
}
示例3: buildArgumentsInterlace
func (server *Server) buildArgumentsInterlace(arguments *list.List, params imageserver.Params) error {
interlace, _ := params.GetBool("no_interlace")
if !interlace {
arguments.PushBack("-interlace")
arguments.PushBack("Line")
}
return nil
}
示例4: buildArgumentsTrim
func (server *Server) buildArgumentsTrim(arguments *list.List, params imageserver.Params) error {
trim, _ := params.GetBool("trim")
if trim {
// We must execute trim first. (order of operations)
arguments.PushFront("-trim")
}
return nil
}
示例5: buildArgumentsGrey
func (server *Server) buildArgumentsGrey(arguments *list.List, params imageserver.Params) error {
grey, _ := params.GetBool("grey")
if grey {
arguments.PushBack("-colorspace")
arguments.PushBack("GRAY")
}
return nil
}
示例6: buildArgumentsExtent
func (server *Server) buildArgumentsExtent(arguments *list.List, params imageserver.Params, width int, height int) error {
if width == 0 || height == 0 {
return nil
}
if !params.Has("extent") {
return nil
}
extent, err := params.GetBool("extent")
if err != nil {
return err
}
if extent {
arguments.PushBack("-extent")
arguments.PushBack(fmt.Sprintf("%dx%d", width, height))
}
return nil
}
示例7: TestParseQueryBool
func TestParseQueryBool(t *testing.T) {
req, err := http.NewRequest("GET", "http://localhost?bool=true", nil)
if err != nil {
t.Fatal(err)
}
params := imageserver.Params{}
err = ParseQueryBool("bool", req, params)
if err != nil {
t.Fatal(err)
}
b, err := params.GetBool("bool")
if err != nil {
t.Fatal(err)
}
if b != true {
t.Fatal("not equals")
}
}
示例8: TestCorrectionParserParse
func TestCorrectionParserParse(t *testing.T) {
parser := &CorrectionParser{}
req, err := http.NewRequest("GET", "http://localhost?gamma_correction=true", nil)
if err != nil {
t.Fatal(err)
}
params := imageserver.Params{}
err = parser.Parse(req, params)
if err != nil {
t.Fatal(err)
}
res, err := params.GetBool("gamma_correction")
if err != nil {
t.Fatal(err)
}
if res != true {
t.Fatalf("unexpected result: got %t, want %t", res, true)
}
}
示例9: isEnabled
func (prc *CorrectionProcessor) isEnabled(params imageserver.Params) (bool, error) {
if params.Has("gamma_correction") {
return params.GetBool("gamma_correction")
}
return prc.enabled, nil
}
示例10: buildArgumentsResize
func (hdr *Handler) buildArgumentsResize(arguments *list.List, params imageserver.Params) (width int, height int, err error) {
width, err = getDimension("width", params)
if err != nil {
return 0, 0, err
}
height, err = getDimension("height", params)
if err != nil {
return 0, 0, err
}
if width == 0 && height == 0 {
return 0, 0, nil
}
widthString := ""
if width != 0 {
widthString = strconv.Itoa(width)
}
heightString := ""
if height != 0 {
heightString = strconv.Itoa(height)
}
resize := fmt.Sprintf("%sx%s", widthString, heightString)
if params.Has("fill") {
fill, err := params.GetBool("fill")
if err != nil {
return 0, 0, err
}
if fill {
resize = resize + "^"
}
}
if params.Has("ignore_ratio") {
ignoreRatio, err := params.GetBool("ignore_ratio")
if err != nil {
return 0, 0, err
}
if ignoreRatio {
resize = resize + "!"
}
}
if params.Has("only_shrink_larger") {
onlyShrinkLarger, err := params.GetBool("only_shrink_larger")
if err != nil {
return 0, 0, err
}
if onlyShrinkLarger {
resize = resize + ">"
}
}
if params.Has("only_enlarge_smaller") {
onlyEnlargeSmaller, err := params.GetBool("only_enlarge_smaller")
if err != nil {
return 0, 0, err
}
if onlyEnlargeSmaller {
resize = resize + "<"
}
}
arguments.PushBack("-resize")
arguments.PushBack(resize)
return width, height, nil
}