mirror of
https://github.com/harness/drone.git
synced 2025-05-19 02:20:03 +08:00

Preparing the support for harness specific API router + http handler, which allows us to have complete control over the rest api naming and functionality, without having to do complex path rewrites or request / reponse rewrites inline.
23 lines
355 B
Go
23 lines
355 B
Go
package request
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
PathParamSpaceRef = "spaceRef"
|
|
)
|
|
|
|
func GetSpaceRef(r *http.Request) (string, error) {
|
|
rawRef, err := ParamOrError(r, PathParamSpaceRef)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
// paths are unescaped and lower
|
|
ref, err := url.PathUnescape(rawRef)
|
|
return strings.ToLower(ref), err
|
|
}
|