A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

43 lines
988 B

  1. /*
  2. * Copyright © 2018 A Bunch Tell LLC.
  3. *
  4. * This file is part of WriteFreely.
  5. *
  6. * WriteFreely is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License, included
  8. * in the LICENSE file in this source code package.
  9. */
  10. package config
  11. import (
  12. "net/http"
  13. "strings"
  14. "time"
  15. )
  16. // FriendlyHost returns the app's Host sans any schema
  17. func (ac AppCfg) FriendlyHost() string {
  18. return ac.Host[strings.Index(ac.Host, "://")+len("://"):]
  19. }
  20. func (ac AppCfg) CanCreateBlogs(currentlyUsed uint64) bool {
  21. if ac.MaxBlogs <= 0 {
  22. return true
  23. }
  24. return int(currentlyUsed) < ac.MaxBlogs
  25. }
  26. // OrDefaultString returns input or a default value if input is empty.
  27. func OrDefaultString(input, defaultValue string) string {
  28. if len(input) == 0 {
  29. return defaultValue
  30. }
  31. return input
  32. }
  33. // DefaultHTTPClient returns a sane default HTTP client.
  34. func DefaultHTTPClient() *http.Client {
  35. return &http.Client{Timeout: 10 * time.Second}
  36. }