Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - optional params #2

Open
Gargo opened this issue Jun 2, 2019 · 2 comments
Open

Feature request - optional params #2

Gargo opened this issue Jun 2, 2019 · 2 comments

Comments

@Gargo
Copy link

Gargo commented Jun 2, 2019

For example I need a library to collect rss from different websites. I need to specify single url only and get/post method only for each website. You library requires to setup all params even if they are not necessary

@emadhegab
Copy link
Owner

You can do that for the other functions

‘’’
var parameters: RequestParams {
return .url(nil)
}

var headers: [String : Any]? {
    return nil
}

‘’’

See if it works for you

@Gargo
Copy link
Author

Gargo commented Jun 2, 2019

@emadhegab
I solved it by the following code:

extension Request {
    var path: String {
        return ""
    }
    var method: HTTPMethod {
        return .get
    }
    var parameters: RequestParams {
        return .url(nil)
    }
    var headers: [String : Any]? {
        return nil
    }
}
enum RTDefaultRequest: Request {
    case `default`
}
extension Operations {
    var request: Request {
        return RTDefaultRequest.default
    }
}

It adds default implementations for these methods and simplifies the development for some cases.

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

No branches or pull requests

2 participants