Skip to content

Commit

Permalink
Remove SetBaseURL() (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eun authored Nov 30, 2020
1 parent 4c8e9d1 commit 6f6280a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 0 additions & 8 deletions hit.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ package hit

import (
"context"
"fmt"
"net/http"

"golang.org/x/xerrors"
Expand Down Expand Up @@ -68,9 +67,6 @@ type Hit interface {
// BaseURL returns the current base url.
BaseURL() string

// SetBaseURL sets the base url.
SetBaseURL(url string, a ...interface{})

// CurrentStep returns the current working step.
CurrentStep() IStep

Expand Down Expand Up @@ -167,10 +163,6 @@ func (hit *hitImpl) BaseURL() string {
return hit.baseURL
}

func (hit *hitImpl) SetBaseURL(url string, a ...interface{}) {
hit.baseURL = fmt.Sprintf(url, a...)
}

func (hit *hitImpl) collectSteps(state StepTime) []IStep {
var collectedSteps []IStep
for i := 0; i < len(hit.steps); i++ {
Expand Down
8 changes: 6 additions & 2 deletions static.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package hit

import (
"context"
"fmt"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -154,7 +155,10 @@ func BaseURL(url string, a ...interface{}) IStep {
When: requestCreateStep,
CallPath: newCallPath("BaseURL", nil),
Exec: func(hit *hitImpl) error {
hit.SetBaseURL(url, a...)
if len(a) > 0 {
url = fmt.Sprintf(url, a...)
}
hit.baseURL = url
return nil
},
}
Expand Down Expand Up @@ -192,7 +196,7 @@ func makeMethodStep(fnName, method, url string, a ...interface{}) IStep {
CallPath: newCallPath(fnName, nil),
Exec: func(hit *hitImpl) error {
hit.request.Method = method
url = misc.MakeURL(hit.BaseURL(), url, a...)
url = misc.MakeURL(hit.baseURL, url, a...)
if url == "" {
hit.request.URL = new(urlpkg.URL)
return nil
Expand Down

0 comments on commit 6f6280a

Please sign in to comment.