chore: auto build docker image for web
This commit is contained in:
parent
fea5649efb
commit
d863eff7de
7 changed files with 91 additions and 4 deletions
14
main.go
14
main.go
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"embed"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/vicanso/elton"
|
||||
|
|
@ -16,6 +17,12 @@ var webFS embed.FS
|
|||
func main() {
|
||||
e := elton.New()
|
||||
|
||||
e.Use(middleware.NewLogger(middleware.LoggerConfig{
|
||||
Format: middleware.LoggerCombined,
|
||||
OnLog: func(s string, _ *elton.Context) {
|
||||
fmt.Println(s)
|
||||
},
|
||||
}))
|
||||
e.Use(middleware.NewDefaultError())
|
||||
e.Use(middleware.NewDefaultBodyParser())
|
||||
|
||||
|
|
@ -28,6 +35,11 @@ func main() {
|
|||
EnableStrongETag: true,
|
||||
}))
|
||||
|
||||
e.GET("/ping", func(c *elton.Context) error {
|
||||
c.BodyBuffer = bytes.NewBufferString("pong")
|
||||
return nil
|
||||
})
|
||||
|
||||
e.GET("/", func(c *elton.Context) error {
|
||||
buf, err := webFS.ReadFile("web/index.html")
|
||||
if err != nil {
|
||||
|
|
@ -46,7 +58,7 @@ func main() {
|
|||
return nil
|
||||
})
|
||||
|
||||
err := e.ListenAndServe(":3000")
|
||||
err := e.ListenAndServe(":7001")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue