diff --git a/.gitignore b/.gitignore index 30d7e91..7e89ff0 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,5 @@ _testmain.go *.prof /vendor +debug #main diff --git a/Dockerfile b/Dockerfile index 4545e88..2d8dab3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,7 @@ LABEL maintainer="MiaoWoo" ENV LANG en_US.UTF-8 -RUN yum install -y fontconfig git nano -RUN git clone https://github.com/powerline/fonts.git --depth=1 && \ - cd fonts && \ - ./install.sh && \ - fc-cache +RUN yum install -y fontconfig WORKDIR /root diff --git a/main b/main index 47c9e26..18fbadf 100755 Binary files a/main and b/main differ diff --git a/main.go b/main.go index 490175a..c60658a 100644 --- a/main.go +++ b/main.go @@ -18,11 +18,20 @@ func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { uid, _ := uuid.NewV4() uuid := "html2pic-" + uid.String() - url, html := r.PostFormValue("url"), r.PostFormValue("html") + var ( + url string + html string + ) + if r.Method == "GET" { + url, html = r.FormValue("url"), r.FormValue("html") + } else { + url, html = r.PostFormValue("url"), r.PostFormValue("html") + } tempFile := *tempDir + "/" + uuid + ".html" if html != "" { ioutil.WriteFile(tempFile, []byte(""+html+""), os.ModeAppend) url = "file://" + tempFile + os.Chmod(tempFile, 0755) defer os.Remove(tempFile) } if url == "" { diff --git a/uuid/g.go b/uuid/generator.go similarity index 100% rename from uuid/g.go rename to uuid/generator.go