mdedetrich / akka-http-webjars   0.5.0

Apache License 2.0 GitHub

Serve static assets from WebJars

Scala versions: 2.13 2.12

Build Status Latest version Apache License

akka-http-webjars

Allows you to serve static assets from WebJars with akka-http.

Usage

Published for Scala 2.12 and Scala 2.13

libraryDependencies ++= Seq(
  "org.mdedetrich" %% "akka-http-webjars" % "0.5.0"
)

Then you simply need to import the org.mdedetrich.akka.http.WebJarsSupport object and add a route, i.e.

import org.mdedetrich.akka.http.WebJarsSupport._
import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route

class Routes {

  private def webJarAssets = pathPrefix("webjars") {
    webJars
  }
  
  val routes: Route = webJarAssets

}

Then you can simply refer to a webjar like so

<head>
  <script src="webjars/es5-shim.min.js">
</head>