Skip to content

Commit

Permalink
♻️ refactor: updated codebase #9
Browse files Browse the repository at this point in the history
  • Loading branch information
arisnguyen215 committed Dec 13, 2023
1 parent 8b61110 commit 0597d5b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apix/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,14 @@ func GetEndpointSample() *EndpointConfig {
}

func NewEndpointOptionsConfig() *EndpointOptionsConfig {
return &EndpointOptionsConfig{}
return &EndpointOptionsConfig{
IsEnabledPingResponse: true,
}
}

func (e *EndpointOptionsConfig) SetEnabledPingResponse(value bool) *EndpointOptionsConfig {
e.IsEnabledPingResponse = value
return e
}

func (e *EndpointOptionsConfig) SetSkipMessageHeader(value bool) *EndpointOptionsConfig {
Expand Down
1 change: 1 addition & 0 deletions apix/api_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type EndpointConfig struct {
}

type EndpointOptionsConfig struct {
IsEnabledPingResponse bool `json:"enabled_ping_response" yaml:"enabled_ping_response"`
SkipMessageHeader bool `json:"skip_message_header" yaml:"skip_message_header"`
SkipMessageRequestBody bool `json:"skip_message_request_body" yaml:"skip_message_request_body"`
SkipMessageResponseBody bool `json:"skip_message_response_body" yaml:"skip_message_response_body"`
Expand Down
3 changes: 3 additions & 0 deletions apix/api_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ func (s *apiServiceImpl) execute(client *restify.Client, endpoint EndpointConfig
request.SetBody(endpoint.Body)
}
response, err = request.Execute(endpoint.Method, fullURL)
if endpoint.TelegramOptions.IsEnabledPingResponse {
go s.alert(endpoint, response, err)
}
return response, err
}

Expand Down

0 comments on commit 0597d5b

Please sign in to comment.