scala - Spray.io directive not registering? -
scala - Spray.io directive not registering? -
i want access path users/{id}/permission
via spray route using post method. reason (and i've tried different configurations) doesn't register route , 405 method not allowed
.
the code below part of pathprefix "users". works, post not.
path(rest / "permission") { id => /** * save permissions object user */ post { entity(as[string]) { body => seek { val uperm = parse[userpermission](body) userpermission.store(uperm) respondwithmediatype(`application/json`) { finish { generate(uperm) } } } grab { case e: com.codahale.jerkson.parsingexception => finish { httpresponse(badrequest, "submitted malformed data.") } } } } ~ /** * grab permissions single user */ { seek { val uperm = userpermission.fetch(id) respondwithmediatype(`application/json`) { finish { generate(uperm) } } } grab { case e: java.lang.nullpointerexception => finish { httpresponse(notfound, "object not found.") } } } } ~
am missing here?
you should't utilize "rest" way, seek "pathelement" instead:
path(pathelement / "permission") { id => ... }
if it's int utilize intnumber, rest if want match "rest" of url end... doesn't create sense way used, should set @ end.
scala spray
Comments
Post a Comment