drone/internal/api/request/path.go
Enver Bisevac f03528e862 [MAINT] initial config for ci linter (#17)
* initial config for ci linter

* more linter work

* linter errors fix

* linter errors fix

* linter conf minor changes
2022-09-19 18:13:18 +02:00

28 lines
405 B
Go

package request
import (
"errors"
"net/http"
"strconv"
"github.com/go-chi/chi"
)
const (
PathIDParamName = "pathId"
)
func GetPathID(r *http.Request) (int64, error) {
rawID := chi.URLParam(r, PathIDParamName)
if rawID == "" {
return 0, errors.New("path id parameter not found in request")
}
id, err := strconv.ParseInt(rawID, 10, 64)
if err != nil {
return 0, err
}
return id, nil
}