ParsePath parses the given request path and returns the processing options and image URL
( ctx context.Context, path string, features *clientfeatures.Features, )
| 196 | |
| 197 | // ParsePath parses the given request path and returns the processing options and image URL |
| 198 | func (p *Parser) ParsePath( |
| 199 | ctx context.Context, |
| 200 | path string, |
| 201 | features *clientfeatures.Features, |
| 202 | ) (o *options.Options, imageURL string, err error) { |
| 203 | if path == "" || path == "/" { |
| 204 | return nil, "", newInvalidURLError(ctx, "invalid path: %s", path) |
| 205 | } |
| 206 | |
| 207 | parts := strings.Split(strings.TrimPrefix(path, "/"), "/") |
| 208 | |
| 209 | if p.config.OnlyPresets { |
| 210 | o, imageURL, err = p.parsePathPresets(ctx, parts, features) |
| 211 | } else { |
| 212 | o, imageURL, err = p.parsePathOptions(ctx, parts, features) |
| 213 | } |
| 214 | |
| 215 | if err != nil { |
| 216 | return nil, "", errctx.Wrap(err) |
| 217 | } |
| 218 | |
| 219 | return o, imageURL, nil |
| 220 | } |
| 221 | |
| 222 | // parsePathOptions parses processing options from the URL path |
| 223 | func (p *Parser) parsePathOptions( |