Groups
Groups
Sign in
Groups
Groups
spray.io User List
Conversations
Labels
About
Send feedback
Help
How to extract all form fields at once?
505 views
Skip to first unread message
Fedor Tokarev
unread,
Nov 26, 2012, 12:23:50 PM
11/26/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to spray...@googlegroups.com
Hello,
I've found this page
https://github.com/spray/spray/wiki/Form-Field-Filters
, where it is noted that I can do this:
content(as[FormData]){ formData =>
}
But that wiki is about 0.9.0 -- a lot of things has happened since then. What is a current way to extract all form fields at once?
Fedor Tokarev
unread,
Nov 27, 2012, 12:04:31 AM
11/27/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to spray...@googlegroups.com
Solution:
def allFormFields: Directive[Map[String,String] :: HNil] = {
extract(_.
request.entity.as
[FormData].right.map(_.fields)).flatMap{
case Right(value) => provide(value)
case Left(_) => reject
}
}
понедельник, 26 ноября 2012 г., 21:23:51 UTC+4 пользователь Fedor Tokarev написал:
Mathias
unread,
Nov 27, 2012, 3:27:22 AM
11/27/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to spray...@googlegroups.com
Fedor,
actually you might want to use the `entity` directive as such:
entity(as[FormData]) { formData =>
...
}
Still, your implementation suggestion is pretty close to how the `entity` directive is implemented:
https://github.com/spray/spray/blob/master/spray-routing/src/main/scala/spray/routing/directives/MarshallingDirectives.scala#L36
Cheers,
Mathias
---
mat...@spray.io
http://spray.io
> --
>
>
Reply all
Reply to author
Forward
0 new messages