Skip to content

Expose response object (res) on locals #716

@elgreg

Description

@elgreg

Is your feature request related to a problem? Please describe.

We'd like to be able to add response headers to things as they're rendered. Specifically, we'd like to be able to add a Surrogate-Key header of a page's author, section, tags, etc when we're rendering the article object. Right now, we can't add to the response based on its content because we don't have access to the response object.

Describe the solution you'd like

Assign locals.res to res in amphora somewhere like this: https://github.com/clay/amphora/blob/master/lib/render.js#L119

locals.res = res

Now model renders and other functions that have access to locals can also do something like locals.res.set("Surrogate-Key", author:${data.author.slug})

Of course, when setting it, one would have to check if it already exists, etc, etc., but this ask is more about getting it on the locals object so it's passed around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions