go fmt
This commit is contained in:
parent
6b1867f35f
commit
ec658520b7
@ -4,14 +4,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/tardisx/discord-auto-upload/assets"
|
"github.com/tardisx/discord-auto-upload/assets"
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
"github.com/tardisx/discord-auto-upload/config"
|
"github.com/tardisx/discord-auto-upload/config"
|
||||||
|
"log"
|
||||||
"mime"
|
"mime"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -26,8 +26,8 @@ type valueStringResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type valueBooleanResponse struct {
|
type valueBooleanResponse struct {
|
||||||
Success bool `json: 'success'`
|
Success bool `json: 'success'`
|
||||||
Value bool `json: 'value'`
|
Value bool `json: 'value'`
|
||||||
}
|
}
|
||||||
|
|
||||||
type errorResponse struct {
|
type errorResponse struct {
|
||||||
@ -123,7 +123,6 @@ func getSetUsername(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func getSetWatch(w http.ResponseWriter, r *http.Request) {
|
func getSetWatch(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
@ -139,7 +138,7 @@ func getSetWatch(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
i, err := strconv.Atoi(r.PostForm.Get("value"))
|
i, err := strconv.Atoi(r.PostForm.Get("value"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response := errorResponse{Success: false, Error: fmt.Sprintf("Bad value for watch: %v", err)}
|
response := errorResponse{Success: false, Error: fmt.Sprintf("Bad value for watch: %v", err)}
|
||||||
@ -155,7 +154,6 @@ func getSetWatch(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
config.Config.Watch = i
|
config.Config.Watch = i
|
||||||
postResponse := valueStringResponse{Success: true, Value: strconv.Itoa(config.Config.Watch)}
|
postResponse := valueStringResponse{Success: true, Value: strconv.Itoa(config.Config.Watch)}
|
||||||
|
|
||||||
@ -179,13 +177,13 @@ func getSetNoWatermark(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
v := r.PostForm.Get("value")
|
v := r.PostForm.Get("value")
|
||||||
|
|
||||||
if v != "0" && v != "1" {
|
if v != "0" && v != "1" {
|
||||||
response := errorResponse{Success: false, Error: fmt.Sprintf("Bad value for nowatermark: %v", err)}
|
response := errorResponse{Success: false, Error: fmt.Sprintf("Bad value for nowatermark: %v", err)}
|
||||||
js, _ := json.Marshal(response)
|
js, _ := json.Marshal(response)
|
||||||
w.Write(js)
|
w.Write(js)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if v == "0" {
|
if v == "0" {
|
||||||
@ -193,14 +191,13 @@ func getSetNoWatermark(w http.ResponseWriter, r *http.Request) {
|
|||||||
} else {
|
} else {
|
||||||
config.Config.NoWatermark = true
|
config.Config.NoWatermark = true
|
||||||
}
|
}
|
||||||
postResponse := valueBooleanResponse{Success: true, Value: config.Config.NoWatermark}
|
postResponse := valueBooleanResponse{Success: true, Value: config.Config.NoWatermark}
|
||||||
|
|
||||||
js, _ := json.Marshal(postResponse)
|
js, _ := json.Marshal(postResponse)
|
||||||
w.Write(js)
|
w.Write(js)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func getSetDirectory(w http.ResponseWriter, r *http.Request) {
|
func getSetDirectory(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Print("ok")
|
log.Print("ok")
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user