Skip to content
This repository was archived by the owner on Sep 7, 2021. It is now read-only.

Does not compile with Vapor 4 RC #1

Closed
jhoogstraat opened this issue Mar 9, 2020 · 1 comment · Fixed by #2
Closed

Does not compile with Vapor 4 RC #1

jhoogstraat opened this issue Mar 9, 2020 · 1 comment · Fixed by #2

Comments

@jhoogstraat
Copy link
Contributor

No description provided.

@jhoogstraat
Copy link
Contributor Author

jhoogstraat commented Mar 12, 2020

As part of this PR the following improvements can be made:

Add case patch to OperationType

Especially relevant when patching/updating is done partially (e.g. only providing the fields to-be-updated).

Add the following extension:

extension QueryEndpoint {
    public func register(to routes: RoutesBuilder) {
        switch operationType {
        case .get:
            routes.get(use: handler)
        case .post:
            routes.post(use: handler)
        case .put:
            routes.put(use: handler)
        case .patch:
            routes.patch(use: handler)
        case .delete:
            routes.delete(use: handler)
        }
    }
}

This allows most routes to drop their implementation of register()

Update Custom to allow for different return values.

Right now T must be returned. This would implicate that the path parameter must be optional.

public final class Custom<T: CorvusModel, R: ResponseEncodable>: QueryEndpoint {
/// The return value of the `.handler()`.
    public typealias Element = R

//...
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant