Documentation
¶
Overview ¶
Copyright © 2025 Vicknesh Suppramaniam <vicknesh@handletec.my>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2025 Vicknesh Suppramaniam <vicknesh@handletec.my>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2025 Vicknesh Suppramaniam <vicknesh@handletec.my>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2025 Vicknesh Suppramaniam <vicknesh@handletec.my>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2025 Vicknesh Suppramaniam <vicknesh@handletec.my>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2025 Vicknesh Suppramaniam <vicknesh@handletec.my>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2025 Vicknesh Suppramaniam <vicknesh@handletec.my>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2025 Vicknesh Suppramaniam <vicknesh@handletec.my>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2025 Vicknesh Suppramaniam <vicknesh@handletec.my>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- type AuthBinderFunc
- type AuthType
- type Headers
- type HookOpt
- type Method
- type Query
- type ReqOpt
- type WebHook
- func (wh *WebHook) MarshalYAML() (any, error)
- func (wh *WebHook) Send(tlsConfig *tls.Config, body []byte, query Query, headers Headers) (err error)
- func (wh *WebHook) SetBasicAuth(username, password string)
- func (wh *WebHook) SetBearerToken(token string)
- func (wh *WebHook) SetCustomToken(headerName, value string)
- func (wh *WebHook) SetHeader(name, value string)
- func (wh *WebHook) String() (str string)
- func (wh *WebHook) UnmarshalYAML(n *yaml.Node) error
- type WebHooks
- func (whs WebHooks) Add(method Method, address string, opt HookOpt) error
- func (whs *WebHooks) ApplyAuth(binder AuthBinderFunc) error
- func (whs WebHooks) Broadcast(tlsCfg *tls.Config, opts ...ReqOpt) error
- func (whs WebHooks) MarshalYAML() (any, error)
- func (whs WebHooks) Remove(method Method, address string) (err error)
- func (whs WebHooks) Send(method Method, tlsCfg *tls.Config, opts ...ReqOpt) error
- func (whs *WebHooks) String() (str string)
- func (whs *WebHooks) UnmarshalYAML(n *yaml.Node) error
Constants ¶
const ( // AuthTypeNone - no authentication required AuthTypeNone = iota + 1 // AuthTypeBasic - username password combination AuthTypeBasic // AuthTypeBearer - bearer token authentication AuthTypeBearer // AuthType - uses custom token authentication AuthTypeToken )
const ( // MethodGet - HTTP GET Method MethodGet = iota + 1 // Method - HTTP POST Method MethodPost // Method - HTTP PUT Method MethodPut // Method - HTTP PATCH Method MethodPatch // Method - HTTP DELETE Method MethodDelete )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthBinderFunc ¶
AuthBinderFunc is invoked once per hook; set creds via wh.SetBasicAuth / wh.SetBearerToken / wh.SetCustomToken as needed.
type AuthType ¶
type AuthType uint8
func (*AuthType) MarshalJSON ¶
func (AuthType) MarshalYAML ¶
func (*AuthType) UnmarshalJSON ¶
type Headers ¶
type Headers httpclient.Headers
func NewHeaders ¶
func NewHeaders() (h Headers)
NewHeaders - initialize headers with default user-agent
type HookOpt ¶
func WithBasicAuth ¶
WithBasicAuth - Authorization: Basic <base64(username:password)>
func WithBearerToken ¶
WithBearerToken - Authorization: Bearer <token> (JWT or opaque)
func WithNoAuth ¶
func WithNoAuth() HookOpt
WithNoAuth - no authentication needed for remote endpoint
type Method ¶
type Method uint8
func (*Method) MarshalJSON ¶
func (Method) MarshalYAML ¶
func (*Method) UnmarshalJSON ¶
type Query ¶
func NewQueryPairs ¶
type WebHook ¶
type WebHook struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Method Method `yaml:"method" json:"method"`
Address string `yaml:"address" json:"address"`
AuthType AuthType `yaml:"authType" json:"authType"`
AuthHeaderName string `yaml:"authHeaderName,omitempty" json:"authHeaderName,omitempty"`
// for auth type basic
Username string `yaml:"username,omitempty" json:"username,omitempty"`
Password string `yaml:"password,omitempty" json:"password,omitempty"`
// for auth type token
Token string `yaml:"token,omitempty" json:"token,omitempty"`
// contains filtered or unexported fields
}
WebHook - remote service to notify based
func NewWebHook ¶
NewWebHook - creates new webhook
func (*WebHook) MarshalYAML ¶
func (*WebHook) Send ¶
func (wh *WebHook) Send(tlsConfig *tls.Config, body []byte, query Query, headers Headers) (err error)
Send - sends the request to the endpoint, no response returned - fire and forget
func (*WebHook) SetBasicAuth ¶
SetBasicAuth - Authorization: Basic <base64(username:password)>
func (*WebHook) SetBearerToken ¶
SetBearerToken - Authorization: Bearer <token> (JWT or opaque token)
func (*WebHook) SetCustomToken ¶
SetCustomToken - sets custom headwe with value e.g., X-Api-Key: <value>
type WebHooks ¶
WebHooks - collection of `WebHook`
func NewWebHooks ¶
func NewWebHooks() (whs WebHooks)
NewWebHooks - create new instance of webhooks to store multiple webhook for different HTTP methods
func (*WebHooks) ApplyAuth ¶
func (whs *WebHooks) ApplyAuth(binder AuthBinderFunc) error
ApplyAuth - applies credentials to every hook using the provided binder.
func (WebHooks) Broadcast ¶
Broadcast - sends the request to all addresses across all methods (concurrently)