Fix README sample code errors
Closes https://github.com/tus/tusd/pull/87
This commit is contained in:
parent
0a8a3e7e51
commit
e89661cbda
14
README.md
14
README.md
|
@ -54,14 +54,17 @@ your own Go program:
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/tus/tusd"
|
||||
"github.com/tus/tusd/filestore"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create a new FileStore instance which is responsible for
|
||||
// storing the uploaded file on disk in the specified directory.
|
||||
// This path _must_ exist before tusd will store uploads in it.
|
||||
// If you want to save them on a different medium, for example
|
||||
// a remote FTP server, you can implement your own storage backend
|
||||
// by implementing the tusd.DataStore interface.
|
||||
|
@ -79,22 +82,23 @@ func main() {
|
|||
// Create a new HTTP handler for the tusd server by providing a configuration.
|
||||
// The StoreComposer property must be set to allow the handler to function.
|
||||
handler, err := tusd.NewHandler(tusd.Config{
|
||||
BasePath: "files/",
|
||||
BasePath: "/files/",
|
||||
StoreComposer: composer,
|
||||
})
|
||||
if err != nil {
|
||||
panic("Unable to create handler: %s", err)
|
||||
panic(fmt.Errorf("Unable to create handler: %s", err))
|
||||
}
|
||||
|
||||
// Right now, nothing has happened since we need to start the HTTP server on
|
||||
// our own. In the end, tusd will start listening on and accept request at
|
||||
// http://localhost:8080/files
|
||||
http.Handle("files/", http.StripPrefix("files/", handler))
|
||||
http.Handle("/files/", http.StripPrefix("/files/", handler))
|
||||
err = http.ListenAndServe(":8080", nil)
|
||||
if err != nil {
|
||||
panic("Unable to listen: %s", err)
|
||||
panic(fmt.Errorf("Unable to listen: %s", err))
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Please consult the [online documentation](https://godoc.org/github.com/tus/tusd)
|
||||
|
|
Loading…
Reference in New Issue