doc: Update use embedmd (include file in .md)
This commit is contained in:
parent
ebb0d398c3
commit
5d1b16d05b
|
@ -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:
|
||||
|
|
12
README.md
12
README.md
|
@ -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")
|
||||
}
|
||||
```
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue