Skip to content

Text-service output can use custom paths#628

Open
donaldgray wants to merge 8 commits into
developfrom
feature/text_custom_path
Open

Text-service output can use custom paths#628
donaldgray wants to merge 8 commits into
developfrom
feature/text_custom_path

Conversation

@donaldgray

@donaldgray donaldgray commented Jul 2, 2026

Copy link
Copy Markdown
Member

What does this change?

Resolves #619 - allows control of how text-service paths, in line with https://github.com/dlcs/text-services/blob/main/instructions/alternative-paths.md

X-Forwarded-Host and X-Forwarded-Path are always set when making request. Former is set to Orchestrator URL, latter is set to default value, optionally overridden by TextServiceJob path template.

Additional Changes

Introduced new PathTemplate type, in favour of string for templates. Expresses expectations better and allowed PresentationPathReplacementHelpers and SupportedTemplateOptions to be stored in single place.

Added benefit is that call sites are now much cleaner:

// this
var path = PresentationPathReplacementHelpers.GeneratePresentationPathFromTemplate(template,
            customerId.ToString(), hierarchyPath, resourceId);

// becomes
var path = template.GeneratePath(customerId, hierarchyPath, resourceId);

Made 2 small tweaks in TypedPathTemplateOptions -

  • Don't use static DefaultFormats as Defaults, create a copy instead. Currently changing the overridden values (set via appSettings) would override the baked-in presets.
  • GetPathTemplatesForHost() uses Defaults rather than DefaultFormats to get all templates. Previously GetPathTemplatesForHost() would always used the DefaultFormats value, rather than Defaults. This is only used in PathRewriteParser

Configuration Changes

Optional TextServiceJob path template value. See path-customisation.md added with this PR for more details.

@donaldgray donaldgray requested a review from a team as a code owner July 2, 2026 11:26
@donaldgray donaldgray changed the title Feature/text custom path Text-service output can use custom paths Jul 2, 2026
Previous code used DefaultFormats, rather than Defaults, meaning that
the default values couldn't be overridden by standard appSettings.
Small change, keeps call sites cleaner by not needing to always call
.ToString() when passing what is always an int.
Allows customisation of generated paths. Source values from existing
configuration, adding "TextServiceJob" to list of known path formats
Defaults shared a reference with the static DefaultFormats, so binding
config values leaked into the baseline defaults. Copy the baseline per
instance instead.

There's currently no issue with this but fixing as I noticed, it could
bite in the future
PathTemplate is a simple type that maps a path template, it's more
descriptive than string and allows cleaner callsite for generating
paths.
PresentationPathReplacementHelpers and known consts from
SupportedTemplateOptions were folded into single type. No functional
changes.
These paths are output only, we don't want to attempt to parse them
from incoming resources. This may change in the future but for now
remove these templates from parsing logic.
@donaldgray donaldgray force-pushed the feature/text_custom_path branch from f5665b3 to 17af695 Compare July 2, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom Paths

2 participants