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

skinny.micro.base.FormParamsAccessor.scala Maven / Gradle / Ivy

The newest version!
package skinny.micro.base

import skinny.micro._
import skinny.micro.context.SkinnyContext

/**
 * Provides formParams/formMultiParams.
 */
trait FormParamsAccessor extends QueryParamsAccessor { self: SkinnyMicroBase =>

  /**
   * Returns query string multi parameters as a Map value.
   */
  def formMultiParams(implicit ctx: SkinnyContext): MultiParams = {
    multiParams(ctx).map {
      case (k, vs) =>
        queryMultiParams(ctx).find(_._1 == k) match {
          case Some((k, queryValues)) => k -> vs.diff(queryValues)
          case _ => k -> vs
        }
    }
  }

  /**
   * Returns query string parameters as a Map value.
   */
  def formParams(implicit ctx: SkinnyContext): Params = new SkinnyMicroParams(formMultiParams(ctx))

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy