| GET,POST | /url_shortener |
|---|
import Foundation
import ServiceStack
public class url_shortener : Codable
{
/**
* operation type
*/
// @ApiMember(DataType="string", Description="operation type", IsRequired=true, Name="operation", ParameterType="body")
public var operation:operationType?
/**
* url
*/
// @ApiMember(DataType="string", Description="url", IsRequired=true, Name="url", ParameterType="body")
public var url:String
/**
* days to expire
*/
// @ApiMember(DataType="string", Description="days to expire", Name="days", ParameterType="body")
public var days:Double?
required public init(){}
}
public enum operationType : String, Codable
{
case NoOperation
case ShortenUrl
case GetOriginalUrl
case RedirectUrl
}
public class url_shortenerResponse : Codable
{
public var tiny_url:String
public var original_url:String
public var created_date:Date
public var expiry_date:Date?
public var collision:Int?
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /url_shortener HTTP/1.1
Host: milliet.io
Accept: application/json
Content-Type: application/json
Content-Length: length
{"operation":"0x4E71","url":"String","days":0}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"tiny_url":"String","original_url":"String","created_date":"0001-01-01T00:00:00.0000000","expiry_date":"0001-01-01T00:00:00.0000000","collision":0}