Skip extra reader in http server
This commit is contained in:
parent
4d22da5312
commit
cb98d37133
1 changed files with 6 additions and 13 deletions
19
cmd/serve.go
19
cmd/serve.go
|
|
@ -5,7 +5,6 @@ Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
|
@ -109,12 +108,9 @@ func getConvert(c *gin.Context) {
|
||||||
c.Error(err)
|
c.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
extraHeaders := map[string]string{
|
c.Header("X-Image-Width", fmt.Sprintf("%d", width))
|
||||||
"X-Image-Width": fmt.Sprintf("%d", width),
|
c.Header("X-Image-Height", fmt.Sprintf("%d", height))
|
||||||
"X-Image-height": fmt.Sprintf("%d", height),
|
c.Data(http.StatusOK, "x-image/inkpot-epd", converted)
|
||||||
}
|
|
||||||
|
|
||||||
c.DataFromReader(http.StatusOK, int64(len(converted)), "x-image/inkpot-epd", bytes.NewReader(converted), extraHeaders)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func putConvert(c *gin.Context) {
|
func putConvert(c *gin.Context) {
|
||||||
|
|
@ -150,12 +146,9 @@ func putConvert(c *gin.Context) {
|
||||||
c.Error(err)
|
c.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
extraHeaders := map[string]string{
|
c.Header("X-Image-Width", fmt.Sprintf("%d", width))
|
||||||
"X-Image-Width": fmt.Sprintf("%d", width),
|
c.Header("X-Image-Height", fmt.Sprintf("%d", height))
|
||||||
"X-Image-height": fmt.Sprintf("%d", height),
|
c.Data(http.StatusOK, "x-image/inkpot-epd", converted)
|
||||||
}
|
|
||||||
|
|
||||||
c.DataFromReader(http.StatusOK, int64(len(converted)), "x-image/inkpot-epd", bytes.NewReader(converted), extraHeaders)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue