From e89661cbdad0f5b34d86a510319113fef1361251 Mon Sep 17 00:00:00 2001 From: mrezai Date: Wed, 4 Jan 2017 21:30:40 +0100 Subject: [PATCH] Fix README sample code errors Closes https://github.com/tus/tusd/pull/87 --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fdb80df..52a4264 100644 --- a/README.md +++ b/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)