index redirect now can be overriden by environment variable
This commit is contained in:
parent
4abf26fa02
commit
0c23d45667
7
main.go
7
main.go
@ -22,6 +22,7 @@ var client = redis.NewClient(&redis.Options{
|
|||||||
})
|
})
|
||||||
|
|
||||||
var SECRET string
|
var SECRET string
|
||||||
|
var INDEX_GET_REDIRECT = "http://alv.cx"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
@ -38,13 +39,17 @@ func main() {
|
|||||||
SECRET = p
|
SECRET = p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p, ok := os.LookupEnv("INDEX_GET_REDIRECT"); ok {
|
||||||
|
INDEX_GET_REDIRECT = p
|
||||||
|
}
|
||||||
|
|
||||||
log.Fatal(http.ListenAndServe(listenAddress, r))
|
log.Fatal(http.ListenAndServe(listenAddress, r))
|
||||||
}
|
}
|
||||||
|
|
||||||
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Println("indexHandler called")
|
fmt.Println("indexHandler called")
|
||||||
if r.Method != "POST" {
|
if r.Method != "POST" {
|
||||||
http.Redirect(w, r, "http://alv.cx", 302)
|
http.Redirect(w, r, INDEX_GET_REDIRECT, 302)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
readme.md
16
readme.md
@ -13,8 +13,8 @@ sus URL shortener
|
|||||||
|
|
||||||
susmng [-s pls.cx] delete -l shortlink -v confirm
|
susmng [-s pls.cx] delete -l shortlink -v confirm
|
||||||
|
|
||||||
susmng will assume the first server in the 'secrets' section if the -s flag is
|
`susmng` will assume the first server in the `secrets` section of the configuration file if the -s
|
||||||
not provided.
|
flag is not provided.
|
||||||
|
|
||||||
|
|
||||||
## installation
|
## installation
|
||||||
@ -31,20 +31,22 @@ not provided.
|
|||||||
|
|
||||||
#### server environment variables
|
#### server environment variables
|
||||||
|
|
||||||
- `SECRET` - the secret used for signature verification
|
- `SECRET`---the secret used for signature verification
|
||||||
- `LISTEN_ADDRESS` - the address the server is listening on (default is `0.0.0.0:80`)
|
- `LISTEN_ADDRESS`---the address the server is listening on (default is `0.0.0.0:80`)
|
||||||
|
- `INDEX_GET_REDIRECT`---the URL the user should be redirected to if they try to access `/` on the
|
||||||
|
server (default is `http://alv.cx`)
|
||||||
|
|
||||||
### setting up susmng
|
### setting up susmng
|
||||||
|
|
||||||
1. install susmng
|
1. install `susmng`
|
||||||
|
|
||||||
make install-susmng
|
make install-susmng
|
||||||
|
|
||||||
2. create config files
|
2. create configuration files
|
||||||
|
|
||||||
susmng init
|
susmng init
|
||||||
|
|
||||||
3. edit config files (`~/.config/susmng/config.json`) to add your secrets
|
3. edit configuration files (`~/.config/susmng/config.json`) to add your secrets
|
||||||
|
|
||||||
|
|
||||||
![](sus.jpg)
|
![](sus.jpg)
|
||||||
|
Loading…
Reference in New Issue
Block a user