ignore Package.resolved
Ability Management Utility for Vapor Applications.
Add the following to your dependencies in Package.swift.
.package(url: "https://github.com/rb-de0/HotSoda.git", from: "0.1.0")
To use HotSoda, you first need to add Provider to Services.
HotSoda
try services.register(HotSodaProvider())
Conform Models that you want to manage abilities to AbilityProtected.
AbilityProtected
extension User: AbilityProtected { static func canCreate(on request: Request) -> Future<Void> { ... } func canRead(on request: Request) -> Future<User> { ... } func canUpdate(on request: Request) -> Future<User> { ... } func canDelete(on request: Request) -> Future<User> { ... } }
By using AbilityProtectedMiddleware, you can protect abilities for controlling models.
The model must be conformed AbilityProtected & Model & Parameter.
AbilityProtected & Model & Parameter
router.protected(User.self, for: [.create]).post("users", use: UserController().store)
or
router.protect(User.self, for: [.create]) { router in router.post("users", use: UserController().store) }
Models through middleware is cached, so you can get models as follows without DB connections.
try request.requireControllable(User.self)
HotSoda is released under the MIT License. See the LICENSE file for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
HotSoda
Ability Management Utility for Vapor Applications.
Prerequisites
Swift
OS
Installation
Add the following to your dependencies in Package.swift.
Usage
Provider
To use
HotSoda
, you first need to add Provider to Services.AbilityProtected
Conform Models that you want to manage abilities to
AbilityProtected
.AbilityProtectedMiddleware
By using AbilityProtectedMiddleware, you can protect abilities for controlling models.
The model must be conformed
AbilityProtected & Model & Parameter
.or
Models through middleware is cached, so you can get models as follows without DB connections.
LICENSE
HotSoda is released under the MIT License. See the LICENSE file for more info.