update shorturl to use badgerhold
This commit is contained in:
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
a := &Image{}
|
||||
a := &image{}
|
||||
httpsrv.RegisterModule("image", a.config)
|
||||
|
||||
httpsrv.HttpRegister("image", httpsrv.HttpRoutes{
|
||||
@@ -30,12 +30,12 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
type image struct {
|
||||
store string
|
||||
maxSize int64
|
||||
}
|
||||
|
||||
func (a *Image) config(config map[string]string) {
|
||||
func (a *image) config(config map[string]string) {
|
||||
a.store = "data/"
|
||||
if config["store"] != "" {
|
||||
a.store = config["store"]
|
||||
@@ -55,7 +55,7 @@ func (a *Image) config(config map[string]string) {
|
||||
log.Noticef("Image: store max-size set to [%d]", a.maxSize)
|
||||
}
|
||||
|
||||
func (a *Image) get(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *image) get(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
|
||||
name := vars["name"]
|
||||
@@ -85,14 +85,14 @@ func (a *Image) get(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
pr := readutil.NewPreviewReader(f)
|
||||
|
||||
mime, err := ReadMIME(pr, name)
|
||||
mime, _ := readutil.ReadMIME(pr, name)
|
||||
w.Header().Set("Content-Type", mime)
|
||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
|
||||
io.Copy(w, pr.Drain())
|
||||
_, _ = io.Copy(w, pr.Drain())
|
||||
}
|
||||
|
||||
func (a *Image) put(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *image) put(w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
|
||||
if h := r.Header.Get("Content-Length"); h != "" {
|
||||
@@ -151,6 +151,6 @@ func isImageOrVideo(in io.Reader) bool {
|
||||
return filetype.IsImage(buf) || filetype.IsVideo(buf)
|
||||
}
|
||||
|
||||
func (a *Image) getStyle(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *image) getStyle(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user