diff --git a/.gitignore b/.gitignore index 31e85d4..2b249de 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /tus_data +/gopath diff --git a/dev.sh b/dev.sh new file mode 100644 index 0000000..fa12ab8 --- /dev/null +++ b/dev.sh @@ -0,0 +1,9 @@ +#!/usr/bin/bash + +# usage: source dev.sh +# +# dev.sh simplifies development by setting up a local GOPATH. +export GOPATH=`pwd`/gopath +src_dir="${GOPATH}/src/github.com/tus/tusd" +mkdir -p "${src_dir}" +ln -fs "`pwd`/src" "${src_dir}" diff --git a/src/cmd/tusd/main.go b/src/cmd/tusd/main.go index 744bf7d..083381b 100644 --- a/src/cmd/tusd/main.go +++ b/src/cmd/tusd/main.go @@ -2,13 +2,23 @@ package main import ( "log" + tushttp "github.com/tus/tusd/src/http" + "net/http" + "os" ) func main() { log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds) log.Printf("tusd started") - if err := serveHttp(); err != nil { - log.Fatal(err) + addr := ":1080" + if port := os.Getenv("TUSD_PORT"); port != "" { + addr = ":" + port + } + log.Printf("servering clients at http://localhost%s", addr) + + handler := tushttp.NewHandler() + if err := http.ListenAndServe(addr, handler); err != nil { + panic(err) } } diff --git a/src/http/client.go b/src/http/client.go new file mode 100644 index 0000000..d02cfda --- /dev/null +++ b/src/http/client.go @@ -0,0 +1 @@ +package http diff --git a/src/http/doc.go b/src/http/doc.go new file mode 100644 index 0000000..f525b46 --- /dev/null +++ b/src/http/doc.go @@ -0,0 +1,3 @@ +// Package http contains a client and server implementation of the tus protocol +// and is meant to be used by other applications. +package http diff --git a/src/http/handler.go b/src/http/handler.go new file mode 100644 index 0000000..f33e0ae --- /dev/null +++ b/src/http/handler.go @@ -0,0 +1,14 @@ +package http + +import ( + "net/http" +) + +func NewHandler() *Handler { + return &Handler{} +} + +type Handler struct {} + +func (h *Handler) ServeHTTP(http.ResponseWriter, *http.Request) { +}