apiV0MediaHandler, apiV0TreeHandler
parent
06deb5d0c9
commit
7223cb6af9
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"local/router"
|
"local/router"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -92,7 +93,18 @@ func (server *Server) apiV0MediaHandler(w http.ResponseWriter, r *http.Request)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) apiV0MediaIDHandler(w http.ResponseWriter, r *http.Request) error {
|
func (server *Server) apiV0MediaIDHandler(w http.ResponseWriter, r *http.Request) error {
|
||||||
return errors.New("not impl" + r.URL.Path)
|
id := path.Base(r.URL.Path)
|
||||||
|
f, err := os.Open(path.Join(server.root, "media", id))
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
io.Copy(w, f)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) apiV0FilesHandler(w http.ResponseWriter, r *http.Request) error {
|
func (server *Server) apiV0FilesHandler(w http.ResponseWriter, r *http.Request) error {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue