initial commit
This commit is contained in:
commit
6d0890e280
68 changed files with 5986 additions and 0 deletions
25
pkg/op/endpoint.go
Normal file
25
pkg/op/endpoint.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package op
|
||||
|
||||
import "strings"
|
||||
|
||||
type Endpoint string
|
||||
|
||||
func (e Endpoint) Relative() string {
|
||||
return relativeEndpoint(string(e))
|
||||
}
|
||||
|
||||
func (e Endpoint) Absolute(host string) string {
|
||||
return absoluteEndpoint(host, string(e))
|
||||
}
|
||||
|
||||
func (e Endpoint) Validate() error {
|
||||
return nil //TODO:
|
||||
}
|
||||
|
||||
func absoluteEndpoint(host, endpoint string) string {
|
||||
return strings.TrimSuffix(host, "/") + relativeEndpoint(endpoint)
|
||||
}
|
||||
|
||||
func relativeEndpoint(endpoint string) string {
|
||||
return "/" + strings.TrimPrefix(endpoint, "/")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue