GET | /genres | ||
---|---|---|---|
GET | /genres/{GenreId} |
import Foundation
import ServiceStack
public class QueryGenres : QueryDb<Genres>, IGet
{
public var genreId:Int?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case genreId
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
genreId = try container.decodeIfPresent(Int.self, forKey: .genreId)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if genreId != nil { try container.encode(genreId, forKey: .genreId) }
}
}
public class Genres : Codable
{
public var genreId:Int
public var name:String
required public init(){}
}
public class Todo : Codable
{
public var id:Int
public var text:String
public var isFinished:Bool
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.
GET /genres HTTP/1.1 Host: blazor-gallery.servicestack.net Accept: application/json
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"offset":0,"total":0,"results":[{"genreId":0,"name":"String"}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}