@@ -189,60 +189,28 @@ func (c *ServeCommand) Execute(args []string) error {
189189 return nil
190190 }
191191
192- UseCssColumns = cfg .CssColumns
193- Namespace = cfg .Namespace
192+ * AppConfig = * cfg
194193 RepoName = GetBookmarksRepoName ()
195- SiteTitle = cfg .Title
196- NoFooter = cfg .NoFooter
197- DevMode = version == "dev"
198- if cfg .DevMode != nil {
199- DevMode = * cfg .DevMode
200- }
201194
202- if cfg .GithubServer != "" {
203- GithubServer = cfg .GithubServer
204- }
205- if cfg .GitlabServer != "" {
206- GitlabServer = cfg .GitlabServer
207- }
208- if cfg .FaviconCacheDir != "" {
209- FaviconCacheDir = cfg .FaviconCacheDir
210- }
211- if cfg .FaviconCacheSize != 0 {
212- FaviconCacheSize = cfg .FaviconCacheSize
213- } else {
214- FaviconCacheSize = DefaultFaviconCacheSize
195+ if AppConfig .DevMode == nil {
196+ isDev := version == "dev"
197+ AppConfig .DevMode = & isDev
215198 }
216- if cfg .CommitsPerPage != 0 {
217- CommitsPerPage = cfg .CommitsPerPage
218- } else {
219- CommitsPerPage = DefaultCommitsPerPage
220- }
221- if cfg .LocalGitPath != "" {
222- LocalGitPath = cfg .LocalGitPath
223- }
224- if cfg .DBConnectionProvider != "" {
225- DBConnectionProvider = cfg .DBConnectionProvider
199+
200+ if AppConfig .FaviconCacheSize == 0 {
201+ AppConfig .FaviconCacheSize = DefaultFaviconCacheSize
226202 }
227- if cfg . DBConnectionString != "" {
228- DBConnectionString = cfg . DBConnectionString
203+ if AppConfig . CommitsPerPage == 0 {
204+ AppConfig . CommitsPerPage = DefaultCommitsPerPage
229205 }
230- githubID := cfg .GithubClientID
231- githubSecret := cfg .GithubSecret
232- gitlabID := cfg .GitlabClientID
233- gitlabSecret := cfg .GitlabSecret
234- externalUrl := strings .TrimRight (cfg .ExternalURL , "/" )
235- redirectUrl := JoinURL (externalUrl , "oauth2Callback" )
236- GithubClientID = githubID
237- GithubClientSecret = githubSecret
238- GitlabClientID = gitlabID
239- GitlabClientSecret = gitlabSecret
240- OauthRedirectURL = redirectUrl
241206
242- SetProviderOrder (cfg .ProviderOrder )
207+ externalUrl := strings .TrimRight (AppConfig .ExternalURL , "/" )
208+ AppConfig .OauthRedirectURL = JoinURL (externalUrl , "oauth2Callback" )
209+
210+ SetProviderOrder (AppConfig .ProviderOrder )
243211
244212 SessionName = "gobookmarks"
245- SessionStore = sessions .NewCookieStore (loadSessionKey (cfg ))
213+ SessionStore = sessions .NewCookieStore (loadSessionKey (* AppConfig ))
246214 if len (ProviderNames ()) == 0 {
247215 return errors .New ("no providers compiled" )
248216 }
@@ -263,7 +231,7 @@ func (c *ServeCommand) Execute(args []string) error {
263231 }).Methods ("GET" )
264232
265233 // Development helpers to toggle layout mode
266- if DevMode {
234+ if * AppConfig . DevMode {
267235 r .HandleFunc ("/_css" , runHandlerChain (EnableCssColumnsAction , redirectToHandler ("/" ))).Methods ("GET" )
268236 r .HandleFunc ("/_table" , runHandlerChain (DisableCssColumnsAction , redirectToHandler ("/" ))).Methods ("GET" )
269237 }
@@ -357,7 +325,7 @@ func (c *ServeCommand) Execute(args []string) error {
357325 log .Printf ("gobookmarks: %s, commit %s, built at %s" , version , commit , date )
358326 SetVersion (version , commit , date )
359327 RepoName = GetBookmarksRepoName ()
360- log .Printf ("Redirect URL configured to: %s" , redirectUrl )
328+ log .Printf ("Redirect URL configured to: %s" , AppConfig . OauthRedirectURL )
361329 log .Println ("Server started on http://localhost:8080" )
362330 log .Println ("Server started on https://localhost:8443" )
363331
@@ -730,7 +698,7 @@ func fileExists(filename string) bool {
730698 return ! os .IsNotExist (err )
731699}
732700
733- func loadSessionKey (cfg Config ) []byte {
701+ func loadSessionKey (cfg Configuration ) []byte {
734702 if cfg .SessionKey != "" {
735703 return []byte (cfg .SessionKey )
736704 }
0 commit comments