Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Isuru-Nanayakkara/HttpManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HttpManager

This is a simple HTTP library. I'm doing this as a little experiment and a learning experience. Currently able to execute GET and POST requests with parameters, custom headers and post form data.


Install

CocoaPods (< v0.36)
  • Create a Podfile.
  • Add the line, pod 'HttpManager', :git => 'https://github.com/Isuru-Nanayakkara/HttpManager.git'.
  • Run pod install.
  • Add import HttpManager to the files where you want to use the library.
Manually
  • Add the HttpManager.swift file to your project.

Usage

GET

let url = "http://httpbin.org/get"

HttpManager.get(url).execute({ (result, error) -> () in
    println(result)
})

POST

let url = "http://httpbin.org/post"

HttpManager.post(url).execute({ (result, error) -> () in
    println(result)
})

Parameters

let url = "http://httpbin.org/get"
let params = ["show_env": 1]

HttpManager.get(url).parameters(params).execute({ (result, error) -> () in
    println(result)
})

Custom Headers

let url = "http://httpbin.org/headers"
let header = ["X-Custom-Header": "Hello World"]

HttpManager.get(url).headers(header).execute({ (result, error) -> () in
    println(result)
})

Form Data

let url = "http://httpbin.org/post"
let bodyData = ["now": NSDate()]

HttpManager.post(url).data(bodyData).execute({ (result, error) -> () in
    println(result)
})

About

A small library to handle HTTP requests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published