huandu / facebook

A Facebook Graph API SDK For Go.
https://pkg.go.dev/github.com/huandu/facebook
MIT License
1.32k stars 513 forks source link

Allow a way to overwrite Base URL for APP #210

Closed Spazzy757 closed 1 year ago

Spazzy757 commented 1 year ago

Situation

Firstly thank you for adding the effort for creating this library.

I would like to use it for some facebook integrations we are creating however I notice that in the App.ParseCodeInfo is using the defaultSession to make requests. In my general use case we would want a way to overwrite the BaseURL for testing purposes.

I would like to setup a fake server in testing and then run integration tests through my application that will test this functionality end to end (without reaching facebook for various reasons)

Potential Solutions

Maybe allowing the passing of a BaseURL or a Session into this function (either through the struct or through the a parameter) in order to allow this overwrite (I see you are able to overwrite the the BaseURL in the session struct). This would allow us to configure this accordingly

huandu commented 1 year ago

I'd prefer to adding a new field Session in App to customize the session used by ParseCodeInfo and similar methods.

type App struct {
    // The session to send request when parsing tokens or code.
    // If it's not set, default session will be used.
    Session *Session
}
Spazzy757 commented 1 year ago

This would defintely work for my use case

Spazzy757 commented 1 year ago

Is this something you would like a PR on or would you like to tackle it?