本文整理匯總了Golang中github.com/pierrre/imageserver.Params.Empty方法的典型用法代碼示例。如果您正苦於以下問題:Golang Params.Empty方法的具體用法?Golang Params.Empty怎麽用?Golang Params.Empty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pierrre/imageserver.Params
的用法示例。
在下文中一共展示了Params.Empty方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: process
func process(nim image.Image, params imageserver.Params) (image.Image, error) {
if params.Empty() {
return nim, nil
}
width, err := getDimension("width", params)
if err != nil {
return nil, err
}
height, err := getDimension("height", params)
if err != nil {
return nil, err
}
if width == 0 && height == 0 {
return nim, nil
}
interp, err := getInterpolation(params)
if err != nil {
return nil, err
}
mode, err := getModeFunc(params)
if err != nil {
return nil, err
}
nim = mode(width, height, nim, interp)
return nim, nil
}
示例2: Change
// Change implements Processor.
func (proc *Processor) Change(params imageserver.Params) bool {
if !params.Has(Param) {
return false
}
params, err := params.GetParams(Param)
if err != nil {
return true
}
if params.Empty() {
return false
}
if params.Has("width") {
return true
}
if params.Has("height") {
return true
}
if params.Has("interpolation") {
return true
}
if params.Has("mode") {
return true
}
return false
}
示例3: Parse
// Parse implements Parser.
func (parser *Parser) Parse(req *http.Request, params imageserver.Params) error {
p := imageserver.Params{}
err := parse(req, p)
if err != nil {
if err, ok := err.(*imageserver.ParamError); ok {
err.Param = Param + "." + err.Param
}
return err
}
if !p.Empty() {
params.Set(Param, p)
}
return nil
}
示例4: validate
func (srv *ValidateParamsServer) validate(params imageserver.Params) error {
if params.Empty() {
return nil
}
err := validateDimension("width", srv.WidthMax, params)
if err != nil {
return err
}
err = validateDimension("height", srv.HeightMax, params)
if err != nil {
return err
}
return nil
}
示例5: Change
// Change implements imageserver/image.Processor.
func (prc *RotateProcessor) Change(params imageserver.Params) bool {
if !params.Has(rotateParam) {
return false
}
params, err := params.GetParams(rotateParam)
if err != nil {
return true
}
if params.Empty() {
return false
}
if params.Has("rotation") {
return true
}
return false
}
示例6: Change
// Change implements imageserver/image.Processor.
func (prc *ResizeProcessor) Change(params imageserver.Params) bool {
if !params.Has(resizeParam) {
return false
}
params, err := params.GetParams(resizeParam)
if err != nil {
return true
}
if params.Empty() {
return false
}
if params.Has("width") {
return true
}
if params.Has("height") {
return true
}
return false
}
示例7: Handle
// Handle implements imageserver.Handler.
func (hdr *Handler) Handle(im *imageserver.Image, params imageserver.Params) (*imageserver.Image, error) {
if !params.Has(param) {
return im, nil
}
params, err := params.GetParams(param)
if err != nil {
return nil, err
}
if params.Empty() {
return im, nil
}
im, err = hdr.handle(im, params)
if err != nil {
if err, ok := err.(*imageserver.ParamError); ok {
err.Param = param + "." + err.Param
}
return nil, err
}
return im, nil
}
示例8: Process
// Process implements Processor.
func (prc *Processor) Process(nim image.Image, params imageserver.Params) (image.Image, error) {
if !params.Has(Param) {
return nim, nil
}
params, err := params.GetParams(Param)
if err != nil {
return nil, err
}
if params.Empty() {
return nim, nil
}
nim, err = prc.process(nim, params)
if err != nil {
if err, ok := err.(*imageserver.ParamError); ok {
err.Param = fmt.Sprintf("%s.%s", Param, err.Param)
}
return nil, err
}
return nim, nil
}
示例9: Get
// Get implements Server.
func (server *Server) Get(params imageserver.Params) (*imageserver.Image, error) {
im, err := server.Server.Get(params)
if err != nil {
return nil, err
}
if !params.Has(globalParam) {
return im, nil
}
params, err = params.GetParams(globalParam)
if err != nil {
return nil, err
}
if params.Empty() {
return im, nil
}
im, err = server.process(im, params)
if err != nil {
if err, ok := err.(*imageserver.ParamError); ok {
err.Param = globalParam + "." + err.Param
}
return nil, err
}
return im, nil
}