Skip to content

scalajs-io/type-is

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeIs API for Scala.js

type-is - Infer the content-type of a request.

Description

Infer the content-type of a request.

Build Dependencies

Build/publish the SDK locally

 $ sbt clean publish-local

Running the tests

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

Examples

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'
})

Artifacts and Resolvers

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") 

Releases

No releases published

Packages

No packages published

Languages