AlamofireでRequest Headerに AccessTokenなどを設定してGETで通信して、Rails4.x でそれらを受け取る

  • 1
    Like
  • 0
    Comment
More than 1 year has passed since last update.

忘れていたので、復習の意味でメモ。

AlamofireでCustom HeadersでGET

let URL = NSURL(string: "https://onedari.please")!
let mutableURLRequest = NSMutableURLRequest(URL: URL)
let message = "tabetai"
mutableURLRequest.HTTPMethod = "GET"
mutableURLRequest.setValue(message, forHTTPHeaderField: "Oniku")
let manager = Alamofire.Manager.sharedInstance

manager.request(mutableURLRequest)
  .response { request, response, data, error in
            }
.
.
.

Rails4でHeaderの要素を受け取る

request.headers["Oniku"]