Explorar o código

Merge pull request #46 from dickeyxxx/readme/not-found

added example on using ServeFiles
Javier Provecho Fernandez %!s(int64=11) %!d(string=hai) anos
pai
achega
265faff4ba
Modificáronse 1 ficheiros con 16 adicións e 0 borrados
  1. 16 0
      README.md

+ 16 - 0
README.md

@@ -287,6 +287,22 @@ func main() {
 ```
 ```
 
 
 
 
+####Serving static files
+
+Use Engine.ServeFiles(path string, root http.FileSystem):
+
+```go
+func main() {
+    r := gin.Default()
+    r.Static("/assets", "./assets")
+
+    // Listen and server on 0.0.0.0:8080
+    r.Run(":8080")
+}
+```
+
+Note: this will use `httpNotFound` instead of the Router's `NotFound` handler.
+
 ####HTML rendering
 ####HTML rendering
 
 
 Using LoadHTMLTemplates()
 Using LoadHTMLTemplates()