-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (37 loc) · 1.06 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"net/http"
"strconv"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
//whoisServerList()
loadConfig()
// Echo instance
e := echo.New()
e.HideBanner = true
// Middleware
e.Use(middleware.Logger())
e.Use(middleware.Recover())
// Route => handler
e.GET("/", viewHandler("index.hbs"))
e.POST("/", func(c echo.Context) error {
domain := c.FormValue("domain")
if domain == "" { //LATER: better error checking
return c.Redirect(http.StatusFound, "/")
}
return c.Redirect(http.StatusFound, "/rdap/domain/"+domain)
})
e.GET("/rdap/domain/:domain", rdapHandler)
theStaticHandler := echo.WrapHandler(staticHandler())
e.GET("/status.json", echo.WrapHandler(&Status{}))
e.GET("/robots.txt", theStaticHandler)
e.GET("/favicon.ico", theStaticHandler)
e.GET("/favicon.svg", theStaticHandler)
e.GET("/css/:filename", theStaticHandler)
e.GET("/js/:filename", theStaticHandler)
e.GET("/config.json", configHandler)
// Start server
e.Logger.Fatal(e.Start(bindHost + ":" + strconv.Itoa(port)))
}