arnaucube
arnaucube/goImgServerPublic Self-hosted repository
update
arnaucode idoctnef@openmailbox.org
Wed, 21 Jun 2017 16:10:45 +0200
commit

19d53b1d5bff90bda8a7676e52ee9fa7229b12c7

parent

1e7913074f75e354cad341ecb5d67dfc1e1a6d94

4 files changed, 7 insertions(+), 5 deletions(-)

jump to
M config.json → config.json

@@ -1,8 +1,8 @@

{ + "serverIP": "127.0.0.1", + "serverPort": "3050", "folder": "files", "blockedIPs": [ - "192.168.1.3", - "147.116.48.158" ], "allowedIPs": [ "127.0.0.1"
M handlers.go → handlers.go

@@ -18,7 +18,7 @@ func ImageShow(w http.ResponseWriter, r *http.Request) {

vars := mux.Vars(r) imageName := vars["imageName"] - file, err := ioutil.ReadFile(imageName) + file, err := ioutil.ReadFile(config.Folder + "/" + imageName) if err != nil { fmt.Fprintln(w, err) }

@@ -63,5 +63,5 @@ if err != nil {

fmt.Println(err) } - fmt.Fprintln(w, "url:", fileName) + fmt.Fprintln(w, config.ServerIP+":"+config.ServerPort+"/images/"+fileName) }
M main.go → main.go

@@ -12,5 +12,5 @@ fmt.Println(config)

router := NewRouter() - log.Fatal(http.ListenAndServe(":3050", router)) + log.Fatal(http.ListenAndServe(":"+config.ServerPort, router)) }
M readConfig.go → readConfig.go

@@ -7,6 +7,8 @@ "io/ioutil"

) type Config struct { + ServerIP string `json:"serverIP"` + ServerPort string `json:"serverPort"` Folder string `json:"foldIPs` BlockedIPs []string `json:"blockedIPs"` AllowedIPs []string `json:"allowedIPs"`