changed type of 'response.Content' from interface{] to string
This commit is contained in:
parent
a3830ff1d5
commit
092f047d14
4 changed files with 7 additions and 3 deletions
2
go.sum
2
go.sum
|
@ -13,3 +13,5 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
// struct for server responses
|
||||
type response struct {
|
||||
StatusCode int
|
||||
Content interface{}
|
||||
Content string
|
||||
error error
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@ func registerHandlers() {
|
|||
func serveRandomImageName(writer http.ResponseWriter, request *http.Request) {
|
||||
timestamp := time.Now().UnixMilli()
|
||||
var response response
|
||||
response.Content, response.error = internal.GetRandomImage()
|
||||
response.Content, response.Size, response.error = internal.GetRandomImage()
|
||||
if response.error != nil {
|
||||
response.StatusCode = 404
|
||||
}
|
||||
response.send(writer)
|
||||
loggo.DebugTimed("served random image '"+response.Content.(string)+"'", timestamp)
|
||||
loggo.DebugTimed("served random image '"+response.Content+"'", timestamp)
|
||||
}
|
||||
|
||||
// request url: '/image' - serve an image
|
||||
|
|
|
@ -33,6 +33,8 @@ func streamColorPalette(writer http.ResponseWriter, image string, amount int, al
|
|||
algorithm = strings.ToLower(algorithm)
|
||||
if algorithm == "wu" {
|
||||
algo = 0
|
||||
} else {
|
||||
algorithm = "wsm"
|
||||
}
|
||||
colors, error := color_thief.GetPaletteFromFile(image, amount, algo)
|
||||
if error != nil {
|
Loading…
Reference in a new issue