refactor: NewStep

This commit is contained in:
debugtalk
2021-12-08 13:20:23 +08:00
parent 99972064ab
commit a301266227
6 changed files with 110 additions and 102 deletions

View File

@@ -2,32 +2,32 @@ package hrp
import "fmt"
// implements IStep interface
type stepRequestExtraction struct {
// StepRequestExtraction implements IStep interface.
type StepRequestExtraction struct {
step *TStep
}
// WithJmesPath sets the JMESPath expression to extract from the response.
func (s *stepRequestExtraction) WithJmesPath(jmesPath string, varName string) *stepRequestExtraction {
func (s *StepRequestExtraction) WithJmesPath(jmesPath string, varName string) *StepRequestExtraction {
s.step.Extract[varName] = jmesPath
return s
}
// Validate switches to step validation.
func (s *stepRequestExtraction) Validate() *stepRequestValidation {
return &stepRequestValidation{
func (s *StepRequestExtraction) Validate() *StepRequestValidation {
return &StepRequestValidation{
step: s.step,
}
}
func (s *stepRequestExtraction) Name() string {
func (s *StepRequestExtraction) Name() string {
return s.step.Name
}
func (s *stepRequestExtraction) Type() string {
func (s *StepRequestExtraction) Type() string {
return fmt.Sprintf("request-%v", s.step.Request.Method)
}
func (s *stepRequestExtraction) ToStruct() *TStep {
func (s *StepRequestExtraction) ToStruct() *TStep {
return s.step
}