pheymann / typedapi

Build your web API on the type level.
MIT License
161 stars 10 forks source link

ClientManager enhancment #31

Closed wookievx closed 6 years ago

wookievx commented 6 years ago

Following the great effort made to publish 0.1.0 I tried to incorporate typedapi to my new project unfortunately i encountered the following limitation of the ClientManager. It forces user to specify port on which the following endpoint is available but unfortunately it is not covering all possible cases, as address without port does not necessarily mean that request will be made using protocol default port (443 or 80). I think that this issue can be fixed quite easily without breaking the existing code with the following implementation of ClientManager:

/** Provides a supported client instance and some basic configuration. */
final case class ClientManager[C](client: C, host: String, port: Option[Int]) {

  val base = port match {
    case Some(p) => s"$host:$p"
    case None => host
  }
}
object ClientManager {
   def apply[C](client: C, host: String, port: Int) = ClientManager(client, host, Some(port))
}
pheymann commented 6 years ago

Hi @wookievx , thanks again for the feedback. I really appreciate it.

This use case sounds indeed necessary. I will implement the change this Friday and I will also try to release it then.

Cheers

pheymann commented 6 years ago

Incorporated the change into 0.2.0-RC1 which should be available on Maven central in a few hours. The changes are in #34 .

I will create a final release next week.