fix: custom absolute endpoints
This commit is contained in:
parent
30d8dec409
commit
660519a19f
4 changed files with 41 additions and 16 deletions
|
@ -2,14 +2,28 @@ package op
|
|||
|
||||
import "strings"
|
||||
|
||||
type Endpoint string
|
||||
type Endpoint struct {
|
||||
path string
|
||||
url string
|
||||
}
|
||||
|
||||
func NewEndpoint(path string) Endpoint {
|
||||
return Endpoint{path: path}
|
||||
}
|
||||
|
||||
func NewEndpointWithURL(path, url string) Endpoint {
|
||||
return Endpoint{path: path, url: url}
|
||||
}
|
||||
|
||||
func (e Endpoint) Relative() string {
|
||||
return relativeEndpoint(string(e))
|
||||
return relativeEndpoint(e.path)
|
||||
}
|
||||
|
||||
func (e Endpoint) Absolute(host string) string {
|
||||
return absoluteEndpoint(host, string(e))
|
||||
if e.url != "" {
|
||||
return e.url
|
||||
}
|
||||
return absoluteEndpoint(host, e.path)
|
||||
}
|
||||
|
||||
func (e Endpoint) Validate() error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue