-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
46 lines (36 loc) · 1.19 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
package main
import (
"github.com/Andrewpqc/muxi-promotion-service/utils"
"github.com/Andrewpqc/muxi-promotion-service/controls"
"github.com/kataras/iris"
"github.com/kataras/iris/middleware/basicauth"
)
func newApp() *iris.Application {
app := iris.Default()
authConfig := basicauth.Config{
Users: utils.GetBasicAuthInfo(),
Realm: "Authorization Required", // defaults to "Authorization Required"
//Expires: time.Duration(30) * time.Minute,
}
authentication := basicauth.New(authConfig)
app.Get("/", func(ctx iris.Context) {
ctx.StatusCode(iris.StatusOK)
ctx.WriteString("<h1>Hello, Welcome to use Muxi Promotion Service")
})
app.Get("/promotion/",controls.ProcessPromotionRequest)
// to party
needAuth := app.Party("/api/v1.0", authentication)
{
needAuth.Get("/private-promotion-link/", controls.GetPrivatePromotionLink)
needAuth.Get("/clean/",controls.CleanDB)
needAuth.Get("/statistic/",controls.GetStatistic)
needAuth.Get("/top/{n:int}/",controls.GetTopX)
needAuth.Get("/rank/{id:string}/",controls.GetRank)
needAuth.Get("/range/",controls.GetPageNationInfo)
}
return app
}
func main() {
app := newApp()
app.Run(iris.Addr(":8080"),iris.WithoutVersionChecker)
}