type-is - Infer the content-type of a request.
Infer the content-type of a request.
$ sbt clean publish-local
Before running the tests the first time, you must ensure the npm packages are installed:
$ npm install
Then you can run the tests:
$ sbt test
import io.scalajs.nodejs.http.Http
import io.scalajs.npm.typeis.TypeIs
import scalajs.js
Http.createServer( (req, res) => {
// req.headers.content-type = 'application/json'
import TypeIs._
is(req, js.Array("json")) // 'json'
is(req, js.Array("html", "json")) // 'json'
is(req, js.Array("application/*")) // 'application/json'
is(req, js.Array("application/json")) // 'application/json'
})
To add the TypeIs
binding to your project, add the following to your build.sbt:
libraryDependencies += "io.scalajs.npm" %%% "type-is" % "0.5.0"
Optionally, you may add the Sonatype Repository resolver:
resolvers += Resolver.sonatypeRepo("releases")