如何在Scala中将反应式Publisher转换为简单Stream?

时间:2019-03-01 14:00:08

标签: scala reactive-streams

是否可以将org.reactivestreams.Publisher实例转换为scala.Stream?如果可能,该怎么办?

1 个答案:

答案 0 :(得分:1)

以下内容将为您工作吗?

const express = require('express')
const bodyParser = require('body-parser')

const app = express() 
const port = 5000 
app.use(bodyParser.json()) 
// response
app.post('/', (req, res) => {
  console.log(req.body)

  res.send({
    replies: [{
        type: 'quickReplies',
        content: {
          title: 'Sorry, but I could not find any results for your request :(',
          buttons: [{ title: 'get quiz', value: 'quiz' }],
        },
      },)
})

app.post('/errors', (req, res) => {
  console.log(req.body) 
  res.send() 
}) 

app.listen(port, () => { 
  console.log('Server is running on port 5000') 
})