MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / applyExpiresOption

Method applyExpiresOption

options/parser/apply.go:450–467  ·  view source on GitHub ↗
(ctx context.Context, o *options.Options, args []string)

Source from the content-addressed store, hash-verified

448}
449
450func (p *Parser) applyExpiresOption(ctx context.Context, o *options.Options, args []string) error {
451 if err := p.ensureMaxArgs(ctx, keys.Expires, args, 1); err != nil {
452 return err
453 }
454
455 timestamp, err := strconv.ParseInt(args[0], 10, 64)
456 if err != nil {
457 return newInvalidArgumentError(ctx, keys.Expires, args[0], "unix timestamp")
458 }
459
460 if timestamp > 0 && timestamp < time.Now().Unix() {
461 return newOptionArgumentError(ctx, keys.Expires, "Expired URL")
462 }
463
464 o.Set(keys.Expires, time.Unix(timestamp, 0))
465
466 return nil
467}
468
469func (p *Parser) applyStripMetadataOption(ctx context.Context, o *options.Options, args []string) error {
470 return p.parseBool(ctx, o, keys.StripMetadata, args...)

Callers 1

applyURLOptionMethod · 0.95

Calls 4

ensureMaxArgsMethod · 0.95
newInvalidArgumentErrorFunction · 0.85
newOptionArgumentErrorFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected