Merge branch 'accept-url-as-base64-string' into 'master'
Accept URL as base64 string in scrape request See merge request saburly/kiviscraplib!2
This commit was merged in pull request #2.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package webserver
|
package webserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
b64 "encoding/base64"
|
||||||
c "gitlab.com/saburly/kiviscraplib/config"
|
c "gitlab.com/saburly/kiviscraplib/config"
|
||||||
"gitlab.com/saburly/kiviscraplib/structures"
|
"gitlab.com/saburly/kiviscraplib/structures"
|
||||||
"gitlab.com/saburly/kiviscraplib/utils"
|
"gitlab.com/saburly/kiviscraplib/utils"
|
||||||
@@ -41,13 +42,16 @@ func httpHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utils.IsValidUrl(url[0]) {
|
decodedUrlBytes, _ := b64.StdEncoding.DecodeString(url[0])
|
||||||
|
decodedUrl := string(decodedUrlBytes)
|
||||||
|
|
||||||
|
if !utils.IsValidUrl(decodedUrl) {
|
||||||
respondWithError(w, 401, "url is malformed")
|
respondWithError(w, 401, "url is malformed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
request := structures.Request{
|
request := structures.Request{
|
||||||
Url: url[0],
|
Url: decodedUrl,
|
||||||
Response: make(chan structures.Response),
|
Response: make(chan structures.Response),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user