fix main.css not being served on /topics/

panic when we try to reference an agent which doesn't exist in gen router init
This commit is contained in:
Azareal 2021-02-18 09:37:20 +10:00
parent 1f0713bb27
commit de2221f243
2 changed files with 30 additions and 16 deletions

View File

@ -873,15 +873,22 @@ func init() {
co.SetReverseAgentMapEnum(reverseAgentMapEnum) co.SetReverseAgentMapEnum(reverseAgentMapEnum)
co.SetOSMapEnum(osMapEnum) co.SetOSMapEnum(osMapEnum)
co.SetReverseOSMapEnum(reverseOSMapEnum) co.SetReverseOSMapEnum(reverseOSMapEnum)
c.Chrome = agentMapEnum["chrome"]
c.Firefox = agentMapEnum["firefox"] g := func(n string) int {
ame := agentMapEnum a, ok := agentMapEnum[n]
if !ok {
panic("name not found in agentMapEnum")
}
return a
}
c.Chrome = g("chrome")
c.Firefox = g("firefox")
c.SimpleBots = []int{ c.SimpleBots = []int{
ame["semrush"], g("semrush"),
ame["ahrefs"], g("ahrefs"),
ame["python"], g("python"),
ame["go"], //g("go"),
ame["curl"], g("curl"),
} }
} }

View File

@ -465,15 +465,22 @@ func init() {
co.SetReverseAgentMapEnum(reverseAgentMapEnum) co.SetReverseAgentMapEnum(reverseAgentMapEnum)
co.SetOSMapEnum(osMapEnum) co.SetOSMapEnum(osMapEnum)
co.SetReverseOSMapEnum(reverseOSMapEnum) co.SetReverseOSMapEnum(reverseOSMapEnum)
c.Chrome = agentMapEnum["chrome"]
c.Firefox = agentMapEnum["firefox"] g := func(n string) int {
ame := agentMapEnum a, ok := agentMapEnum[n]
if !ok {
panic("name not found in agentMapEnum")
}
return a
}
c.Chrome = g("chrome")
c.Firefox = g("firefox")
c.SimpleBots = []int{ c.SimpleBots = []int{
ame["semrush"], g("semrush"),
ame["ahrefs"], g("ahrefs"),
ame["python"], g("python"),
ame["go"], //g("go"),
ame["curl"], g("curl"),
} }
} }