AaHTTP - Simple, lightweighted, elegant HTTP request encapsulatation in Swift.
- Designed for trivial app network scenario. (JSON based GET/POST request)
- Purely implemented with NSURLSession, without any other dependency.
- Conform Adapter Design Pattern.
AaHTTP
act as frontend which provides all functionality, andAaNet
act as backend provide service forAaHTTP
. Under such design, you can always alternate network backend to other implementation(e.gAFNetowrking
,Alamofire
) without change any code in your project. - Easily customize, less than 200 lines of code with straightforward logic. you can easily do some customization based on your need.
Just drag AaNet.swift
, AaHTTP.swift
from demo project to your project folder. then everything is ready.
- Simple Get Request
aht.shareInstance.fetch("http://yahoo.com").go({ (result) in
print(result)
}) { (error) in
print(error)
}
- Get with parameters
aht.shareInstance.fetch("http://cn.bing.com/dict/").paras(["q":"jeopardize"]).go({ (result) in
print(result)
}) { (error) in
print(error)
}
- Post with parameters
aht.shareInstance.post("http://cn.bing.com/dict/").paras(["q":"jeopardize"]).go({ (result) in
print(result)
}) { (error) in
print(error)
}
- Default parameter:
- Universal hostname:
- JSON integrate:
Just take a look at AaHTTP.swift