github.com/aarzilli/tools@v0.0.0-20151123112009-0d27094f75e0/net/http/upload/register_handlers.go (about)

     1  package upload
     2  
     3  import (
     4  	"bytes"
     5  	"net/http"
     6  
     7  	"github.com/pbberlin/tools/net/http/htmlfrag"
     8  	"github.com/pbberlin/tools/net/http/loghttp"
     9  )
    10  
    11  const UrlUploadSend = "/filesys/post-upload-send"
    12  const UrlUploadReceive = "/filesys/post-upload-receive"
    13  
    14  func InitHandlers() {
    15  	http.HandleFunc(UrlUploadSend, loghttp.Adapter(sendUpload))
    16  	http.HandleFunc(UrlUploadReceive, loghttp.Adapter(receiveUpload))
    17  	http.HandleFunc("/mnt00/", loghttp.Adapter(ServeDsFsFile))
    18  	http.HandleFunc("/mnt01/", loghttp.Adapter(ServeDsFsFile))
    19  	http.HandleFunc("/mnt02/", loghttp.Adapter(ServeDsFsFile))
    20  }
    21  
    22  // userinterface rendered to HTML - not only the strings for title and url
    23  func BackendUIRendered() *bytes.Buffer {
    24  	var b1 = new(bytes.Buffer)
    25  	htmlfrag.Wb(b1, "Upload zip files into dsfs", "")
    26  	htmlfrag.Wb(b1, "send", UrlUploadSend, "via command line or via this form")
    27  	htmlfrag.Wb(b1, "receive", UrlUploadReceive, "receive a plain file or a zip archive")
    28  
    29  	htmlfrag.Wb(b1, "serve file mnt00", "/mnt00/test.jpg", "")
    30  	htmlfrag.Wb(b1, "serve file mnt01", "/mnt01/test.jpg", "")
    31  	htmlfrag.Wb(b1, "serve file mnt02", "/mnt02/test.jpg", "")
    32  
    33  	return b1
    34  }