mirror of
https://github.com/tenox7/wrp.git
synced 2024-11-28 19:49:19 +00:00
add debug option to not delete images and maps from memory
This commit is contained in:
parent
cd5bb94def
commit
66412fa95e
6
wrp.go
6
wrp.go
@ -37,6 +37,7 @@ var (
|
|||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
gifmap = make(map[string]bytes.Buffer)
|
gifmap = make(map[string]bytes.Buffer)
|
||||||
ismap = make(map[string]wrpReq)
|
ismap = make(map[string]wrpReq)
|
||||||
|
nodel bool
|
||||||
)
|
)
|
||||||
|
|
||||||
type wrpReq struct {
|
type wrpReq struct {
|
||||||
@ -129,7 +130,9 @@ func mapServer(out http.ResponseWriter, req *http.Request) {
|
|||||||
log.Printf("Unable to find map %s\n", req.URL.Path)
|
log.Printf("Unable to find map %s\n", req.URL.Path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !nodel {
|
||||||
defer delete(ismap, req.URL.Path)
|
defer delete(ismap, req.URL.Path)
|
||||||
|
}
|
||||||
n, err := fmt.Sscanf(req.URL.RawQuery, "%d,%d", &w.X, &w.Y)
|
n, err := fmt.Sscanf(req.URL.RawQuery, "%d,%d", &w.X, &w.Y)
|
||||||
if err != nil || n != 2 {
|
if err != nil || n != 2 {
|
||||||
fmt.Fprintf(out, "n=%d, err=%s\n", n, err)
|
fmt.Fprintf(out, "n=%d, err=%s\n", n, err)
|
||||||
@ -153,7 +156,9 @@ func imgServer(out http.ResponseWriter, req *http.Request) {
|
|||||||
log.Printf("Unable to find image %s\n", req.URL.Path)
|
log.Printf("Unable to find image %s\n", req.URL.Path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !nodel {
|
||||||
defer delete(gifmap, req.URL.Path)
|
defer delete(gifmap, req.URL.Path)
|
||||||
|
}
|
||||||
out.Header().Set("Content-Type", "image/gif")
|
out.Header().Set("Content-Type", "image/gif")
|
||||||
out.Header().Set("Content-Length", strconv.Itoa(len(gifbuf.Bytes())))
|
out.Header().Set("Content-Length", strconv.Itoa(len(gifbuf.Bytes())))
|
||||||
out.Header().Set("Cache-Control", "max-age=0")
|
out.Header().Set("Cache-Control", "max-age=0")
|
||||||
@ -274,6 +279,7 @@ func main() {
|
|||||||
flag.StringVar(&addr, "l", ":8080", "Listen address:port, default :8080")
|
flag.StringVar(&addr, "l", ":8080", "Listen address:port, default :8080")
|
||||||
flag.BoolVar(&head, "h", false, "Headed mode - display browser window")
|
flag.BoolVar(&head, "h", false, "Headed mode - display browser window")
|
||||||
flag.BoolVar(&debug, "d", false, "Debug ChromeDP")
|
flag.BoolVar(&debug, "d", false, "Debug ChromeDP")
|
||||||
|
flag.BoolVar(&nodel, "n", false, "Do not delete maps and gif images in memory")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if head {
|
if head {
|
||||||
headless = false
|
headless = false
|
||||||
|
Loading…
Reference in New Issue
Block a user