drone/internal/api/request/repo.go
Johannes Batzill fad6e18898 Introduce Controller for Repo, Space, User, and ServiceAccount (#25)
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.
2022-10-03 18:56:49 -07:00

23 lines
357 B
Go

package request
import (
"net/http"
"net/url"
"strings"
)
const (
PathParamRepoRef = "repositoryRef"
)
func GetRepoRef(r *http.Request) (string, error) {
rawRef, err := ParamOrError(r, PathParamRepoRef)
if err != nil {
return "", err
}
// paths are unescaped and lower
ref, err := url.PathUnescape(rawRef)
return strings.ToLower(ref), err
}