Fix README sample code errors

This commit is contained in:
mrezai 2016-12-26 19:57:52 +03:30
parent f4810ff429
commit 08e34d20a8
1 changed files with 5 additions and 4 deletions

View File

@ -54,6 +54,7 @@ your own Go program:
package main package main
import ( import (
"fmt"
"github.com/tus/tusd" "github.com/tus/tusd"
"github.com/tus/tusd/filestore" "github.com/tus/tusd/filestore"
"net/http" "net/http"
@ -66,7 +67,7 @@ func main() {
// a remote FTP server, you can implement your own storage backend // a remote FTP server, you can implement your own storage backend
// by implementing the tusd.DataStore interface. // by implementing the tusd.DataStore interface.
store := filestore.FileStore{ store := filestore.FileStore{
Path: "./uploads", Path: "./uploads", // The path must exist
} }
// A storage backend for tusd may consist of multiple different parts which // A storage backend for tusd may consist of multiple different parts which
@ -83,16 +84,16 @@ func main() {
StoreComposer: composer, StoreComposer: composer,
}) })
if err != nil { if err != nil {
panic("Unable to create handler: %s", err) panic(fmt.Sprintf("Unable to create handler: %s", err))
} }
// Right now, nothing has happened since we need to start the HTTP server on // 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 // our own. In the end, tusd will start listening on and accept request at
// http://localhost:8080/files // http://localhost:8080/files
http.Handle("files/", http.StripPrefix("files/", handler)) http.Handle("/files/", http.StripPrefix("/files/", handler))
err = http.ListenAndServe(":8080", nil) err = http.ListenAndServe(":8080", nil)
if err != nil { if err != nil {
panic("Unable to listen: %s", err) panic(fmt.Sprintf("Unable to listen: %s", err))
} }
} }
``` ```