mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 05:20:26 +00:00
Merge pull request #45 from hugmouse/fix-no-hypha-connection-reset
Panic fix (#44)
This commit is contained in:
commit
d2792ff83d
12
main.go
12
main.go
@ -85,8 +85,16 @@ func handlerUpdateHeaderLinks(w http.ResponseWriter, rq *http.Request) {
|
|||||||
// Redirect to a random hypha.
|
// Redirect to a random hypha.
|
||||||
func handlerRandom(w http.ResponseWriter, rq *http.Request) {
|
func handlerRandom(w http.ResponseWriter, rq *http.Request) {
|
||||||
log.Println(rq.URL)
|
log.Println(rq.URL)
|
||||||
var randomHyphaName string
|
var (
|
||||||
i := rand.Intn(hyphae.Count())
|
randomHyphaName string
|
||||||
|
amountOfHyphae int = hyphae.Count()
|
||||||
|
)
|
||||||
|
if amountOfHyphae == 0 {
|
||||||
|
HttpErr(w, http.StatusNotFound, util.HomePage, "There are no hyphae",
|
||||||
|
"It is not possible to display a random hypha because the wiki does not contain any hyphae")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
i := rand.Intn(amountOfHyphae)
|
||||||
for h := range hyphae.YieldExistingHyphae() {
|
for h := range hyphae.YieldExistingHyphae() {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
randomHyphaName = h.Name
|
randomHyphaName = h.Name
|
||||||
|
Loading…
Reference in New Issue
Block a user