All Downloads are FREE. Search and download functionalities are using the official Maven repository.

spice.http.server.CORSSupport.scala Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
package spice.http.server

import rapid.Task
import spice.http.{Headers, HttpExchange}

trait CORSSupport extends HttpServer {
  protected def allowOrigin: String = "*"

  override protected def preHandle(exchange: HttpExchange): Task[HttpExchange] = super
    .preHandle(exchange)
    .flatMap { exchange =>
      exchange.modify { response =>
        Task.pure(response.withHeader(Headers.Response.`Access-Control-Allow-Origin`(allowOrigin)))
      }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy