From 9ca138628023b926ddf07cbd2e93562b8e782cf6 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 21 Feb 2024 01:29:25 +0700 Subject: all: add global HTTP headers for Target The Headers field on Target define the global headers that will be send along with all HTTPTarget or WebSocketTarget. The same header can also be defined on HTTPTarget that override the value of Target. --- example.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'example.go') diff --git a/example.go b/example.go index 1d8747f..3a72fbf 100644 --- a/example.go +++ b/example.go @@ -210,6 +210,8 @@ func (ex *Example) registerWebSocketEndpoints() (err error) { } func (ex *Example) registerTargetHTTP() (err error) { + const headerAuthorization = `Authorization` + var targetHTTP = &Target{ ID: `example_http`, Name: `Example HTTP`, @@ -219,6 +221,12 @@ func (ex *Example) registerTargetHTTP() (err error) { Duration: 10 * time.Second, RatePerSecond: 1, }, + Headers: KeyFormInput{ + headerAuthorization: FormInput{ + Label: `Authorization`, + Hint: `Global authorization header.`, + }, + }, Vars: KeyFormInput{ `A`: FormInput{ Label: `A`, @@ -235,6 +243,10 @@ func (ex *Example) registerTargetHTTP() (err error) { Path: pathExample, RequestType: libhttp.RequestTypeQuery, Headers: KeyFormInput{ + headerAuthorization: FormInput{ + Label: `Authorization`, + Hint: `Global authorization header.`, + }, `X-Get`: FormInput{ Label: `X-Get`, Hint: `Custom HTTP header to be send.`, -- cgit v1.3