@@ -48,12 +48,11 @@ type options struct {
4848}
4949
5050type tmplOptions struct {
51- Opts options
52- URL string
53- IncludePath string
54- Dir string
55- UserAgent string
56- ForceUserAgent bool // DOUBT: This is the only way to ensure all the requests have the same User-Agent. Do we want to force it?
51+ Opts options
52+ URL string
53+ IncludePath string
54+ Dir string
55+ UserAgent string
5756}
5857
5958const configTemplate = `
6362 urls: [ "{{ .URL }}" ]
6463 includePaths: [ "{{ .IncludePath }}" ]
6564jobs:
66- {{ if .ForceUserAgent }}
67- - type: script
68- parameters:
69- name: set-user-agent
70- type: httpsender
71- action: add
72- engine: "ECMAScript : Graal.js"
73- inline: |-
74- function sendingRequest(msg, initiator, helper) {
75- msg.getRequestHeader().setHeader("User-Agent", "{{ .UserAgent }}");
76- }
77- function responseReceived(msg, initiator, helper) {}
78- {{ end }}
7965{{ if .Opts.OpenapiUrl }}
8066- type: openapi
8167 parameters:
@@ -188,7 +174,7 @@ var portPool *pool = createPortPool(13000, 5)
188174
189175func main () {
190176 run := func (ctx context.Context , target , assetType , optJSON string , state checkstate.State ) (err error ) {
191- logger := check .NewCheckLog ( checkName )
177+ logger := check .NewCheckLogFromContext ( ctx , checkName )
192178 var opt options
193179 if optJSON != "" {
194180 if err = json .Unmarshal ([]byte (optJSON ), & opt ); err != nil {
@@ -229,12 +215,11 @@ func main() {
229215 }
230216 sb := new (strings.Builder )
231217 err = tmpl .Execute (sb , tmplOptions {
232- Opts : opt ,
233- URL : targetURL .String (),
234- Dir : tempDir ,
235- IncludePath : includePathRegex ,
236- UserAgent : userAgent ,
237- ForceUserAgent : false ,
218+ Opts : opt ,
219+ URL : targetURL .String (),
220+ Dir : tempDir ,
221+ IncludePath : includePathRegex ,
222+ UserAgent : userAgent ,
238223 })
239224 if err != nil {
240225 return fmt .Errorf ("unable to execute template: %w" , err )
0 commit comments