// Code generated by ogen, DO NOT EDIT. package oas import ( "net/http" "net/url" "github.com/go-faster/errors" "github.com/ogen-go/ogen/conv" "github.com/ogen-go/ogen/middleware" "github.com/ogen-go/ogen/ogenerrors" "github.com/ogen-go/ogen/uri" "github.com/ogen-go/ogen/validate" ) // RedirectLongURLParams is parameters of redirectLongURL operation. type RedirectLongURLParams struct { // Hash of shorten URL. Hash string } func unpackRedirectLongURLParams(packed middleware.Parameters) (params RedirectLongURLParams) { { key := middleware.ParameterKey{ Name: "hash", In: "path", } params.Hash = packed[key].(string) } return params } func decodeRedirectLongURLParams(args [1]string, argsEscaped bool, r *http.Request) (params RedirectLongURLParams, _ error) { // Decode path: hash. if err := func() error { param := args[0] if argsEscaped { unescaped, err := url.PathUnescape(args[0]) if err != nil { return errors.Wrap(err, "unescape path") } param = unescaped } if len(param) > 0 { d := uri.NewPathDecoder(uri.PathDecoderConfig{ Param: "hash", Value: param, Style: uri.PathStyleSimple, Explode: false, }) if err := func() error { val, err := d.DecodeValue() if err != nil { return err } c, err := conv.ToString(val) if err != nil { return err } params.Hash = c return nil }(); err != nil { return err } } else { return validate.ErrFieldRequired } return nil }(); err != nil { return params, &ogenerrors.DecodeParamError{ Name: "hash", In: "path", Err: err, } } return params, nil }