1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2026-04-23 19:41:06 +02:00
Files
2026-03-23 22:35:07 +06:00

40 lines
766 B
Go

package optionsparser
import "context"
// Parser creates Options instances
type Parser struct {
config *Config // Parser configuration
presets map[string][]urlOption // Parsed presets
}
// New creates new Parser instance
func New(ctx context.Context, config *Config) (*Parser, error) {
if err := config.Validate(); err != nil {
return nil, err
}
p := &Parser{
config: config,
presets: make(map[string][]urlOption),
}
if err := p.parsePresets(); err != nil {
return nil, err
}
if err := p.validatePresets(ctx); err != nil {
return nil, err
}
return p, nil
}
func (p *Parser) IsSecurityOptionsAllowed(ctx context.Context) error {
if p.config.AllowSecurityOptions {
return nil
}
return newSecurityOptionsError(ctx)
}