Rename --host => --root-url
This commit is contained in:
28
router.go
28
router.go
@@ -19,13 +19,13 @@ const urlKeyExpr = "{key:[A-Za-z0-9-_]{4,}}"
|
||||
const urlKeyWithExtExpr = urlKeyExpr + "{ext:\\.[A-Za-z0-9-_]+}"
|
||||
|
||||
type rushlink struct {
|
||||
db *db.Database
|
||||
fs *db.FileStore
|
||||
host *url.URL
|
||||
db *db.Database
|
||||
fs *db.FileStore
|
||||
rootURL *url.URL
|
||||
}
|
||||
|
||||
func (rl *rushlink) Host() *url.URL {
|
||||
return rl.host
|
||||
func (rl *rushlink) RootURL() *url.URL {
|
||||
return rl.rootURL
|
||||
}
|
||||
|
||||
func (rl *rushlink) recoveryMiddleware(next http.Handler) http.Handler {
|
||||
@@ -80,21 +80,19 @@ func (w *statusResponseWriter) WriteHeader(statusCode int) {
|
||||
}
|
||||
|
||||
// StartMainServer starts the main http server listening on addr.
|
||||
func StartMainServer(addr string, db *db.Database, fs *db.FileStore, rawhost *string) {
|
||||
var host *url.URL
|
||||
if rawhost != nil {
|
||||
func StartMainServer(addr string, db *db.Database, fs *db.FileStore, rawRootURL string) {
|
||||
var rootURL *url.URL
|
||||
if rawRootURL != "" {
|
||||
var err error
|
||||
host, err = url.Parse(*rawhost)
|
||||
rootURL, err = url.Parse(rawRootURL)
|
||||
if err != nil {
|
||||
log.Fatalln(errors.Wrap(err, "could not parse host flag"))
|
||||
log.Fatalln(errors.Wrap(err, "could not parse rootURL flag"))
|
||||
}
|
||||
} else {
|
||||
log.Println("warning: the --host flag will be required in the future")
|
||||
}
|
||||
rl := rushlink{
|
||||
db: db,
|
||||
fs: fs,
|
||||
host: host,
|
||||
db: db,
|
||||
fs: fs,
|
||||
rootURL: rootURL,
|
||||
}
|
||||
|
||||
// Initialize Gorilla router
|
||||
|
||||
Reference in New Issue
Block a user