PerlDancer / PerlDancer/Dancer2

Allow Mutable serializer to render templates?

Open
#1,556 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement Needs Rework Question
Dominant language
Perl
Stars
604
Forks
288
Avg merge
1d 5h
Merged PRs (30d)
5

Description

It could be useful to return a data structure from a route handler and have it automatically serialized to JSON/XML or rendered in a template depending on Accept: header supplied by the user. Right now we have a Mutable serializer which chooses a serializer based on headers, but no way to render a template if user asks for text/html instead.

Mojolicious has respond_to helper which achieves this. Could Mutable serializer be extended to allow similar things? Right now it's not obvious how it would determine the template to render.

Feel free to point out the obvious solution I am missing, talk me out of returning HTML or JSON from the same route, or suggest alternative API designs. I can help with the implementation too, once there is consensus on how it should behave.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Mutable serializer behavior for Accept headers and the linked Mojolicious respond_to helper. The issue does not identify files or tests; the work is done when the project has agreed on an API and clear template-selection behavior for HTML alongside JSON/XML responses.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.