title: How to create a `enum Router: URLRequestConvertible` with some predefined parameters
body: <p>I'm using <a href="https://github.com/Alamofire/Alamofire" rel="nofollow">Alamofire</a> for my requests on a library project. </p>
  
  <p>I'm trying to use an <code>enum Router: URLRequestConvertible</code> to handle the routes and the queries but I've some parameters that should be set only once and some that should have default values and I don't know handle them.</p>
  
  <h1>Sample code</h1>
  
  <p>This is what I have so far:</p>
  
  <h2>My <code>ResultFromat</code> enum</h2>
  
  <pre><code>/// Available result formats
  enum ResultFormat: String {
    case XML = "xml"
    case JSON = "json"
  }
  </code></pre>
  
  <h2>My <code>Router</code> enum</h2>
  
  <p>Here there are one parameter that is fixed and should be set upon creation (<code>apiId</code>) and one that has a default value (<code>resFormat</code>) but don't mangage to make the <code>init</code> method work.</p>
  
  <pre><code>enum Router: URLRequestConvertible {
    static let API_BASE = "http://sbslocal/api2/"
  
    /// API ID to use in the API calls
    static let apiId : String
  
    /// Format to receive the response
    static var resFormat = ResultFormat.JSON
  
    // MARK: - Enum initialzer
  
    init(apiID: String) {
      Router.apiId = apiID
    }
  
    case Search(query: String)
    case ViewDetail(id: Int)
  
    // ... the rest of the cases ...
  
    // MARK: URLRequestConvertible
  
  
  
     var URLRequest: NSURLRequest {
      let (path: String, parameters: [String: AnyObject]?) = {
        /// Set the basic URL paameters
        var params = ["apiID": Router.API_ID, "format": Router.RESULT_FORMAT.rawValue]
        switch self {
        case .Search(let query):
          // Add the specific parameters for this case (i.e. query)
          params["query"] = query
          return ("/search", params)
          // ... the rest fo the cases
        }
      }()
  
      let URL = NSURL(string: Router.API_BASE)!
      let URLRequest = NSURLRequest(URL: URL.URLByAppendingPathComponent(path))
      let encoding = Alamofire.ParameterEncoding.URL
  
      return encoding.encode(URLRequest, parameters: parameters).0
    }
  
  
  }
  </code></pre>
  
  <p>I've checked with different posibilities for the initialization but none of them seems to work. Any help woudl be apreciated.</p>