-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
51 lines (38 loc) · 871 Bytes
/
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
49
50
51
package main
import (
"log"
"mime"
"net/http"
"os"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
var (
domain string
)
func main() {
port, _ := os.LookupEnv("PORT")
domain, _ = os.LookupEnv("DOMAIN")
if port == "" {
port = "80"
}
if domain == "" {
log.Fatal("DOMAIN env variable need to be set")
}
_ = mime.AddExtensionType(".js", "application/javascript")
_ = mime.AddExtensionType(".css", "text/css")
e := echo.New()
e.HideBanner = true
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
}))
e.GET("/", home)
e.GET("/player/*", player)
e.GET("/v1/jwplayer6/ping.gif", stats)
e.GET("/v1/error/ping.gif", statsError)
e.GET("/canPlayAds.json", canPlayAds)
e.Logger.Fatal(e.Start(":" + port))
}
func home(c echo.Context) error {
return c.String(http.StatusOK, "JWPlayer")
}