Skip to content

Add Response.html convenience constructor #381

Description

@namzug16

Problem to Solve

Not an actual problem, but on SSR apps returning html or html fragments is pretty common, and currently

 Response.ok(
   body: Body.fromString(
     myHtml,
     mimeType: MimeType.html,
   ),
 )

feels too verbose

Proposal

A minimal and simple constructor for html responses

Response.html(
  final String html, {
  final int statusCode = 200,
  final Headers? headers,
}) : this(
       statusCode,
       body: Body.fromString(html, mimeType: MimeType.html),
       headers: headers ?? Headers.empty(),
     );

Use Case

x

Alternatives

x

Additional context

No response

How experienced are you with this library?

Intermediate - Familiar with the basics or have used it in a few projects

Are you interested in working on a PR for this?

  • I want to work on this

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestuxIssues related to the user experience working with Relic.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions