title: How should I respond with different status codes to a GET request in Spray?
body: <p>For POST and PUT requests I use the following syntax:</p>
  
  <pre><code>put {
    entity(as[CaseClass]) { entity =&gt;
       returnsOption(entity).map(result =&gt; complete{(Created, result)})
         .getOrElse(complete{(NotFound, "I couldn't find the parent resource you're modifying")})
    }
  }
  </code></pre>
  
  <p>Now for GET requests I'm trying to do the same, but I can't get it to work analogously to my PUT solution. What is a good way to do this with GET requests?</p>
  
  <p>Update:
  I've got this working with the following hack:</p>
  
  <pre><code>(get &amp; parameters('ignored.?)) {
    //TODO find a way to do this without ignored parameters
    (ingored:Option[String]) =&gt; {
       returnsOption().map(result =&gt; complete(result))
         .getOrElse(complete{(NotFound, "")})
    }
   }
  </code></pre>
  
  <p>I'd expect something similar to be possible with <code>() =&gt;</code> or <code>ctx =&gt;</code> , but that doesn't fly,  because it gives trouble with marshalling:</p>
  
  <pre><code>... could not find implicit value for evidence parameter of type spray.httpx.marshalling.Marshaller[(spray.http.StatusCodes.ClientError, String)]
      }).getOrElse(ctx.complete{(NotFound, "")})
                               ^
  </code></pre>
  
  <p>Could it be that this somehow relates to the fact that I'm using spray-json?</p>