doc: Update use embedmd (include file in .md)

This commit is contained in:
Valentin Omnès 2021-03-15 23:30:19 +01:00
parent ebb0d398c3
commit 5d1b16d05b
2 changed files with 7 additions and 7 deletions

View File

@ -11,7 +11,7 @@ install:
- go get github.com/campoy/embedmd
script:
- embedmd -d *.md
- embedmd -w *.md
- go test -v -covermode=atomic -coverprofile=coverage.out
after_success:

View File

@ -27,9 +27,8 @@ import "github.com/gin-contrib/static"
See the [example](example)
[embedmd]:# (example/simple/example.go go)
#### Serve local file
[embedmd]:# (example/simple/example.go)
```go
package main
@ -56,6 +55,7 @@ func main() {
```
#### Serve embed folder
[embedmd]:# (example/embed/example.go)
```go
package main
@ -68,20 +68,20 @@ import (
"github.com/gin-gonic/gin"
)
//go:embed tmp/server
//go:embed data
var server embed.FS
func main() {
r := gin.Default()
r.Use(static.Serve("/", static.EmbedFolder(server, "tmp/server")))
r.Use(static.Serve("/", static.EmbedFolder(server, "data/server")))
r.GET("/ping", func(c *gin.Context) {
c.String(200, "test")
})
r.NoRoute(func (c *gin.Context) {
r.NoRoute(func(c *gin.Context) {
fmt.Printf("%s doesn't exists, redirect on /\n", c.Request.URL.Path)
c.Redirect(http.StatusMovedPermanently, "/")
})
// Listen and Server in 0.0.0.0:8080
r.Run(":8080")
}
```
```