Last active
May 16, 2016 20:19
-
-
Save goloveychuk/4d6fb265b67095a2192eef95a64d7cd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users: Views.Endpoint/View/Resource, Views.List, Views.Create, Views.Delete, Views.Update//for all just Views.Generic { | |
let model: Users | |
var queryset: QuerySet {//it should support paginate, filter, remove and other simple queries. Maybe this should be `d5` protocols | |
return Users.all | |
} | |
let filters: [User.id.eq, User.name.eq, User.created.range] | |
let authentication: [TokenAuthentication] | |
let serializerClass: UserSerializer | |
//and have ability to override | |
func onList(request) -> Response { | |
return Response(data: ["id": 1]) | |
} | |
} | |
let app = Application { router in | |
router.route("users", Users()) | |
} | |
//somewhere we should put basic configuration. E.g. 90% of views will use same token authentication class | |
//maybe it should be | |
extension View.Endpoint { | |
let authentication: [TokenAuthentication] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment