Giter Site home page Giter Site logo

spray / spray Goto Github PK

View Code? Open in Web Editor NEW
2.5K 2.5K 566.0 20.26 MB

A suite of scala libraries for building and consuming RESTful web services on top of Akka: lightweight, asynchronous, non-blocking, actor-based, testable

Home Page: http://spray.io

License: Other

Scala 63.67% Shell 0.07% HTML 17.81% CSS 12.35% JavaScript 6.10%

spray's Introduction

Superseded by Akka HTTP

spray is no longer maintained and has been superseded by Akka HTTP.

Please check out the migration guide for help with the upgrade.

Commercial support is available from Lightbend.


Documentation

Join the chat at https://gitter.im/spray/spray

Please see http://spray.io/ for all documentation

Code Climate

Build Status

spray's People

Contributors

adamw avatar agaoglu avatar agemooij avatar alexrom avatar analytically avatar andresilva avatar aruediger avatar bthuillier avatar danielwegener avatar dlouwers avatar gildegoma avatar ijuma avatar ivantopo avatar jrudolph avatar ktoso avatar lihaoyi avatar marekzebrowski avatar markdrago avatar markvandertol avatar matsluni avatar mikemckibben avatar mpilquist avatar nkvoll avatar richardbradley avatar savulchik avatar sirthias avatar stig avatar stillalex avatar untoldwind avatar velvia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spray's Issues

slashes at the end of the url

The second test is failing with:
[error] x return the text 'dir' for GET requests to the path /a/
[error] 'Right(file)' is not equal to 'Right(dir)'

class ServiceBuilderSlashSpec extends Specification with SprayTest with ServiceBuilder {

  val simpleService = { path("a") { _.complete("file") } ~ path("a/") {_.complete("dir") } }

  "The simpleService" should {
    "return the text 'file' for GET requests to the path /a" in {
      testService(HttpRequest(GET, "/a")) {
        simpleService
      }.response.content.as[String] mustEqual Right("file")
    }
    "return the text 'dir' for GET requests to the path /a/" in {
      testService(HttpRequest(GET, "/a/")) {
        simpleService
      }.response.content.as[String] mustEqual Right("dir")
    }
  }
}

Is this intended behavior?

django provides a config option and a middleware (i think) to append a slash and retry if no url pattern is matched.
in lift there is no way to distinguish between / and /index, because / apparently does not end with a slash. thats why i am looking for alternatives.

Problems with Cookie Parsing

Hey,

I'm running the latest Spray release and am seeing a strange Cookie parsing error when I'm using Google Chrome.

[cc.spray.http.HttpException: Illegal HTTP header 'Cookie':
Invalid input '"', expected CookieValue, "; " or EOI (line 1, pos 68):
remember=rkapsi:7:ef873b03e76902f2d73ecc68a8c69140; crucibleprefs1="D%3D1302104992324%3Bssyn%3Djava%3Bslp%3Dt%3Basv%3Dfe"
                                                               ^

at cc.spray.http.HttpHeader$.apply(HttpHeader.scala:35)
at cc.spray.ToFromRawConverter$$anonfun$buildHeaders$1.apply(ToFromRawConverter.scala:56)
at cc.spray.ToFromRawConverter$$anonfun$buildHeaders$1.apply(ToFromRawConverter.scala:55)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:93)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:93)
at scala.collection.Iterator$class.foreach(Iterator.scala:652)
at scala.collection.mutable.HashTable$$anon$1.foreach(HashTable.scala:157)
at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:190)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:43)
at scala.collection.mutable.HashMap.foreach(HashMap.scala:93)
at cc.spray.ToFromRawConverter$class.buildHeaders(ToFromRawConverter.scala:55)
at cc.spray.RootService.buildHeaders(RootService.scala:30)
at cc.spray.ToFromRawConverter$class.toSprayRequest(ToFromRawConverter.scala:40)
at cc.spray.RootService.toSprayRequest(RootService.scala:30)
at cc.spray.RootService.cc$spray$RootService$$handleOneService(RootService.scala:78)
at cc.spray.RootService$$anonfun$updateHandler$2.apply(RootService.scala:135)
at cc.spray.RootService$$anonfun$updateHandler$2.apply(RootService.scala:135)
at cc.spray.RootService$$anonfun$receive$1.apply(RootService.scala:63)
at cc.spray.RootService$$anonfun$receive$1.apply(RootService.scala:60)
at akka.actor.Actor$class.apply(Actor.scala:478)
at cc.spray.RootService.apply(RootService.scala:30)
at akka.actor.LocalActorRef.invoke(ActorRef.scala:860)
at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:26)
at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:214)
at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:120)
at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:186)
at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:120)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:181)

getFromFile/getFromResource return empty 404 response on missing file/resource

Better:
If the file/resource does not exist don't complete the request right away with a 404 response but simply reject it (just like an unmatching path/pathPrefix directive does). This usually creates a proper 404 response on the outermost level but has the additional benefit of giving other routes chained in after the 'getFrom...' directive a chance to act.

Akka dependency should be "provided"

We've got a problem now where Spray is pulling in Akka 1.1.3 .. but we have a custom build of 1.1.2 ...

Any reason Spray can't use a "provided" scope on the Akka dependency?

Preload classes at startup

spray 0.5.0 loads a staggering number of classes, some from spray itself and many, many more from parboiled, upon handling of the first request—often enough to take longer than the Akka HTTP timeout. Please do something to preload the classes of spray and its dependencies on startup.

Having said that, spray is brilliant work and I'm loving working with it!

Make Routes return something other than Unit

By having routes return a custom phantom type that can only be "constructed" by completing or rejecting a route we can enforce that routes really do complete or reject the request.
This prevents accidental interruption of the request flow through the routing structure...
We probably still need a "swallow" terminator or something, to allow for intential (and explicit!) request swallowing (e.g. for logging).

Authorization in httpRequest

Hello!

I'm trying to do a test in my project that uses a Rest Interface with authentication. To do the test, I define some interfaces and then I try to connect and it fails because I don't introduce user and password in httpRequest() .
My code is the next:

val mediaType =text/javascript

val expected =
"""
{
"message":"It contains the collection of identifiers of the corpus in the system"
}
"""

  testService(HttpRequest(GET, "/corpus", headers = List(`Accept`(mediaType),`Authorization`(httpCredentials)))) {
    mapService
  }.response.content.as[String] must be(Right(pretty(render(parse(expected)))))

So, I know that I have to specify httpCredentials but I don't know how.
If anyone can explain me how can I do it, I would be so grateful.

Thank you!

methodRejections get precedence in rejection list

When I use this code

put {
  contentAs[Incasso] {
    incasso => {
      ctx => ctx.complete(incasso.cust_name)
    }
  }
} ~
delete {
  ctx => ctx.complete("delete")
} ~
get {
  ctx => ctx.complete(i)
}

Those directives are wrapped with path() directives.

When I do a PUT and it gets a parse error in the unmarshaller, I always get a HTTP method not allowed and never a MalformedRequestContentRejection. When I remove the above get and delete and only use the put, it works and I get a MalformedRequestContentRejection.

This doesn't look like expected behavior as I would expect the last error to be returned to be the error to find it's way back to the client.

Trailing ampersand in query string gives 400

Using a URL of the form:

/someurl?this=that&foo=bar&

... results in a 400 status code and the message "Illegal query string". Looking at the RFC referenced in the Stack Overflow answer (http://stackoverflow.com/questions/6663362/is-a-trailing-ampersand-legal-in-a-url) and with the help of the chosen answer it looks like a trailing ampersand, while pointless, is valid.

We only found this because some of our test frameworks build their query strings lazily but thought you'd like to know.

Add separate "spray-client" module

Many spray applications will also have to query other services.
There are already a few HTTP client library options for Scala developers, however it'd be nice to have one that works directly with sprays existing immutable HTTP model.

The current idea is to provide a very thing layer on top of the excellent AHC library.
In order to enable stand-alone usage we probably need to split spray into separate modules:

  • spray-core
  • spray (depends on spray-core)
  • spray-client (depends on spray-core)

RootService forgets attached HttpServices during restarts

Registered HttpServices are currently held as mutable state within the RootService actor.
This needs to be changed in order to support RootService restarts.
Current idea: pass HttpServices as a fixed list to the RootService constructor

UUID extractor

You have things for grabbing numbers and such out of the URL in routes. Would be nice to have one for UUIDs as well that creates a java.util.UUID.

Add support for request throttling

One feature that might be interesting to see in the core Spray package would be request throttling. The Piston framework for Django supports this:

https://bitbucket.org/jespern/django-piston/wiki/Documentation#!throttling

If a throttle is hit, then returning a 503 response would be great.

Charset negotiation not working

Version 0.5.0 does not properly handle the charset requirements passed via the requests Accept-Charset header.
spray should marshal text content using a charset that is accepted by the client.

Upgrade akka-1.1 branch to scala 2.9.0-1

Since scala 2.9.0-1 fixes only some, but some important bugs. I would suggest upgrading akka to the latest 1.1 version, namely 1.1.2 which is build against scala 2.9.0-1. The only change is the scala version, so upgrading should only incorporate changing the version numbers in sbt build configuration.

Spray's http parser fails on a returned Cookie header

I receive this Cookie-header from a server, while using spray-client:

rl-sticky-key-0d=9260ee80a1a57d51ad41d580acde1272; path=/;

I lookup the Cookie header parsing bit, and the CookieOctet is missing the '/' character. To fix this it should be like so:

def CookieOctet = rule {
ch('\u0021') | ch('\u002f') | ch('\u0023') - "\u002b" | ch('\u002d') - "\u003a" | ch('\u003c') - "\u005b" | ch('\u005d') - "\u007e"
}

I'm not sure if this may not be an actual bad cookie-header, syntax wise.

SBT 0.7.5.RC1 (and .7) for Scala 2.8.1 no longer in public repo

I just freshly started on spray, and wanted to run the template / examples projects. The SBT version 0.7.5.RC1 of the master branch, and 0.7.7 of the develop branch, seems to be no longer available from the default public repositories. Does anyone still have it around?

I understand that switching to SBT 0.10.0 would be an undertaking, giving that the plugin structure seems to have been completely changed (from what I can see at quick glance)

(un)marshaling versioning support

Provide the ability for marshallers and unmarshallers to be registered not only for the request's content type but also for a particular URI match.

Sometimes, a single service may need to produce different message structures for the same operation. That is, a message format would need to be upgraded or changed, but the old message structure should still be supported through a different URI. It would be useful if you can register different marshallers / unmarshallers for different versions of a service with the version being specified in the URI.

For example, the twitter API has a version number included in the beginning of the URI path.
https://api.twitter.com/1/statuses/show/1234566.json
The Twitter API version above is 1, included as the first part of the URI.

The appropriate marshaller or unmarshaller would be chosen according to the version.

You cannot currently register the appropriate marshaller/unmarshaller according to the URI path in Spray.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.