Skip to content

Commit ab8d7fa

Browse files
committed
webserver: allow users calling TibiaDataHTMLDataCollector to request raw body
1 parent 8ca2aa5 commit ab8d7fa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/webserver.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type TibiaDataRequestStruct struct {
6868
Method string `json:"method"` // Request method (default: GET)
6969
URL string `json:"url"` // Request URL
7070
FormData map[string]string `json:"form_data"` // Request form content (used when POST)
71+
RawBody bool `json:"raw_body"` // If set to true the whole content from tibia.com will be passed down
7172
}
7273

7374
// RunWebServer starts the gin server
@@ -258,8 +259,9 @@ func runWebServer() {
258259
// @Router /v4/boostablebosses [get]
259260
func tibiaBoostableBosses(c *gin.Context) {
260261
tibiadataRequest := TibiaDataRequestStruct{
261-
Method: resty.MethodGet,
262-
URL: "https://www.tibia.com/library/?subtopic=boostablebosses",
262+
Method: resty.MethodGet,
263+
URL: "https://www.tibia.com/library/?subtopic=boostablebosses",
264+
RawBody: true,
263265
}
264266

265267
tibiaDataRequestHandler(
@@ -1242,6 +1244,10 @@ func TibiaDataHTMLDataCollector(TibiaDataRequest TibiaDataRequestStruct) (string
12421244
}
12431245
}
12441246

1247+
if TibiaDataRequest.RawBody {
1248+
return string(res.Body()), nil
1249+
}
1250+
12451251
// Convert body to io.Reader
12461252
resIo := bytes.NewReader(res.Body())
12471253

@@ -1254,7 +1260,6 @@ func TibiaDataHTMLDataCollector(TibiaDataRequest TibiaDataRequestStruct) (string
12541260
log.Printf("[error] TibiaDataHTMLDataCollector (URL: %s) error: %s", res.Request.URL, err)
12551261
}
12561262

1257-
// Find of this to get div with class BoxContent
12581263
data, err := doc.Find(".Border_2 .Border_3").Html()
12591264
if err != nil {
12601265
return "", err

0 commit comments

Comments
 (0)