This commit is contained in:
Eduard Urbach 2017-06-05 20:21:06 +02:00
parent c6893a1679
commit 5594b20e8d
4 changed files with 30 additions and 11 deletions

View File

@ -33,7 +33,7 @@
"images/characters/arn-waifu.png"
],
"manifest": {
"theme_color": "rgb(248, 165, 130)",
"theme_color": "#f8a582",
"gcm_sender_id": "941298467524"
},
"ports": {

BIN
images/icons/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

20
logger.go Normal file
View File

@ -0,0 +1,20 @@
package main
// loggerConfig := zap.NewDevelopmentConfig()
// loggerConfig.OutputPaths = append(loggerConfig.OutputPaths, "logs/server.log")
// logger, _ := loggerConfig.Build()
// logTime := func(ctx *aero.Context, next func()) {
// start := time.Now()
// next()
// responseTime := time.Since(start)
// if ctx.StatusCode == 200 {
// logger.Info(ctx.URI(), zap.Duration("responseTime", responseTime), zap.Int("statusCode", ctx.StatusCode))
// } else {
// logger.Warn(ctx.URI(), zap.Duration("responseTime", responseTime), zap.Int("statusCode", ctx.StatusCode))
// }
// }
// app.Use(logTime)

19
main.go
View File

@ -1,7 +1,6 @@
package main
import (
"fmt"
"io/ioutil"
"github.com/aerogo/aero"
@ -52,10 +51,15 @@ func main() {
return ctx.JSON(app.Config.Manifest)
})
app.Get("/ip", func(ctx *aero.Context) string {
ip := ctx.RealIP()
fmt.Println(ip)
return ctx.Text(ip)
app.Get("/favicon.ico", func(ctx *aero.Context) string {
ctx.SetHeader("Content-Type", "image/x-icon")
data, _ := ioutil.ReadFile("images/icons/favicon.ico")
return string(data)
})
// For benchmarks
app.Get("/hello", func(ctx *aero.Context) string {
return ctx.Text("Hello World")
})
// Scripts
@ -67,11 +71,6 @@ func main() {
return js
})
// For testing
app.Get("/hello", func(ctx *aero.Context) string {
return ctx.Text("Hello World")
})
// Let's go
app.Run()
}