make endpoints pointers to enable/disable them
This commit is contained in:
parent
f6cb47fbbb
commit
af22c1a4d8
12 changed files with 229 additions and 93 deletions
|
@ -1,32 +1,46 @@
|
|||
package op
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Endpoint struct {
|
||||
path string
|
||||
url string
|
||||
}
|
||||
|
||||
func NewEndpoint(path string) Endpoint {
|
||||
return Endpoint{path: path}
|
||||
func NewEndpoint(path string) *Endpoint {
|
||||
return &Endpoint{path: path}
|
||||
}
|
||||
|
||||
func NewEndpointWithURL(path, url string) Endpoint {
|
||||
return Endpoint{path: path, url: url}
|
||||
func NewEndpointWithURL(path, url string) *Endpoint {
|
||||
return &Endpoint{path: path, url: url}
|
||||
}
|
||||
|
||||
func (e Endpoint) Relative() string {
|
||||
func (e *Endpoint) Relative() string {
|
||||
if e == nil {
|
||||
return ""
|
||||
}
|
||||
return relativeEndpoint(e.path)
|
||||
}
|
||||
|
||||
func (e Endpoint) Absolute(host string) string {
|
||||
func (e *Endpoint) Absolute(host string) string {
|
||||
if e == nil {
|
||||
return ""
|
||||
}
|
||||
if e.url != "" {
|
||||
return e.url
|
||||
}
|
||||
return absoluteEndpoint(host, e.path)
|
||||
}
|
||||
|
||||
func (e Endpoint) Validate() error {
|
||||
var ErrNilEndpoint = errors.New("nil endpoint")
|
||||
|
||||
func (e *Endpoint) Validate() error {
|
||||
if e == nil {
|
||||
return ErrNilEndpoint
|
||||
}
|
||||
return nil // TODO:
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue