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

com.github.rockjam.httpaste.scalajhttp.package.scala Maven / Gradle / Ivy

There is a newer version: 0.0.6
Show newest version
package com.github.rockjam.httpaste

import scalaj.http._

package object scalajhttp {

  implicit final class ScalajHttpOps(val blueprint: HttpRequestBlueprint) extends AnyVal {
    def asScalajHttp: HttpRequest = {
      val options =
        if (blueprint.options.followRedirect) Seq(HttpOptions.followRedirects(true)) else Seq.empty

      val prepared = Http(blueprint.uri.value)
        .method(blueprint.method.name)
        .headers(blueprint.headers.map(e => e.name -> e.value))
        .options(options)

      blueprint.data map { data =>
        prepared.copy(connectFunc = StringBodyConnectFunc(data.value))
      } getOrElse prepared
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy