fix: init step request

This commit is contained in:
debugtalk
2021-09-23 11:50:17 +08:00
parent 03404f18ab
commit edaaaee6a3
2 changed files with 30 additions and 15 deletions

2
.gitignore vendored
View File

@@ -13,3 +13,5 @@
# Dependency directories (remove the comment below to include it) # Dependency directories (remove the comment below to include it)
# vendor/ # vendor/
__debug_bin

43
step.go
View File

@@ -6,7 +6,6 @@ func Step(name string) *step {
return &step{ return &step{
TStep: &TStep{ TStep: &TStep{
Name: name, Name: name,
Request: &TRequest{},
Variables: make(map[string]interface{}), Variables: make(map[string]interface{}),
}, },
} }
@@ -27,56 +26,70 @@ func (s *step) SetupHook(hook string) *step {
} }
func (s *step) GET(url string) *requestWithOptionalArgs { func (s *step) GET(url string) *requestWithOptionalArgs {
s.TStep.Request.Method = GET s.TStep.Request = &TRequest{
s.TStep.Request.URL = url Method: GET,
URL: url,
}
return &requestWithOptionalArgs{ return &requestWithOptionalArgs{
step: s.TStep, step: s.TStep,
} }
} }
func (s *step) HEAD(url string) *requestWithOptionalArgs { func (s *step) HEAD(url string) *requestWithOptionalArgs {
s.TStep.Request.Method = HEAD s.TStep.Request = &TRequest{
s.TStep.Request.URL = url Method: HEAD,
URL: url,
}
return &requestWithOptionalArgs{ return &requestWithOptionalArgs{
step: s.TStep, step: s.TStep,
} }
} }
func (s *step) POST(url string) *requestWithOptionalArgs { func (s *step) POST(url string) *requestWithOptionalArgs {
s.TStep.Request.Method = POST s.TStep.Request = &TRequest{
s.TStep.Request.URL = url Method: POST,
URL: url,
}
return &requestWithOptionalArgs{ return &requestWithOptionalArgs{
step: s.TStep, step: s.TStep,
} }
} }
func (s *step) PUT(url string) *requestWithOptionalArgs { func (s *step) PUT(url string) *requestWithOptionalArgs {
s.TStep.Request.Method = PUT s.TStep.Request = &TRequest{
s.TStep.Request.URL = url Method: PUT,
URL: url,
}
return &requestWithOptionalArgs{ return &requestWithOptionalArgs{
step: s.TStep, step: s.TStep,
} }
} }
func (s *step) DELETE(url string) *requestWithOptionalArgs { func (s *step) DELETE(url string) *requestWithOptionalArgs {
s.TStep.Request.Method = DELETE s.TStep.Request = &TRequest{
s.TStep.Request.URL = url Method: DELETE,
URL: url,
}
return &requestWithOptionalArgs{ return &requestWithOptionalArgs{
step: s.TStep, step: s.TStep,
} }
} }
func (s *step) OPTIONS(url string) *requestWithOptionalArgs { func (s *step) OPTIONS(url string) *requestWithOptionalArgs {
s.TStep.Request.Method = OPTIONS s.TStep.Request = &TRequest{
s.TStep.Request.URL = url Method: OPTIONS,
URL: url,
}
return &requestWithOptionalArgs{ return &requestWithOptionalArgs{
step: s.TStep, step: s.TStep,
} }
} }
func (s *step) PATCH(url string) *requestWithOptionalArgs { func (s *step) PATCH(url string) *requestWithOptionalArgs {
s.TStep.Request.Method = PATCH s.TStep.Request = &TRequest{
s.TStep.Request.URL = url Method: PATCH,
URL: url,
}
return &requestWithOptionalArgs{ return &requestWithOptionalArgs{
step: s.TStep, step: s.TStep,
} }