Fastify: do not JSON.stringify strings by default

Created on 13 Dec 2017  路  4Comments  路  Source: fastify/fastify

Currently we are converting strings to JSON by default, but possibly we should render them as text-plain, without kicking in the serializer.

enhancement

Most helpful comment

This is slightly related to https://github.com/fastify/fastify/issues/538, but a different use case.

I propose that:

fastify.get('/', (req, reply) => {
  reply.send('hello world')
})

Renders hello world instead of "hello world".

All 4 comments

This is slightly related to https://github.com/fastify/fastify/issues/538, but a different use case.

I propose that:

fastify.get('/', (req, reply) => {
  reply.send('hello world')
})

Renders hello world instead of "hello world".

Agree, I'll do this.

Why?

This can be achieved with

fastify.get('/', (req, reply) => {
  reply.type('text/plain').send('hello world')
})

Because that's not what user will expect.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsumners picture jsumners  路  4Comments

Jegannathan picture Jegannathan  路  3Comments

sebdeckers picture sebdeckers  路  4Comments

kojilab picture kojilab  路  3Comments

aaronshaf picture aaronshaf  路  3Comments