-3

This is a basic controller action in play framework with scala. Can you please explain what is the request variable. Is it the action parameter?

def echo = Action { request =>
          Ok("Got request [" + request + "]")
        }
Suma
  • 33,181
  • 16
  • 123
  • 191
Manvinder Singh
  • 140
  • 1
  • 9
  • The title should give some clue what the question is about. For instance "what is the mening of the variable before "=>" in a scale Action definition?" – Dirk Horsten Aug 02 '18 at 19:18
  • 1
    I don't know... Does [Scala anonymous function syntax and return type](https://stackoverflow.com/questions/41826610/scala-anonymous-function-syntax-and-return-type) cover it, or do you want to know anything more specific about Scala Play Requests what is not covered [by the api](https://www.playframework.com/documentation/2.0.2/api/scala/index.html#play.api.mvc.Action$)? – Andrey Tyukin Aug 02 '18 at 19:35

1 Answers1

1

Well... let me add more information to it.

def echo = Action { request =>
  Ok("Got request [" + request + "]")
}

is actually,

def echo = Action({ request =>
  Ok("Got request [" + request + "]")
})

is actually,

def echo = Action.apply({ request =>
  Ok("Got request [" + request + "]")
})

is actually,

def echo = Action.apply((request: Request) => {
  Ok.apply("Got request [" + request + "]")
})

And, if you are still finding it confusing... then you need to read basics of Scala.

sarveshseri
  • 13,738
  • 28
  • 47