mirror of
https://github.com/warmbly/warmbly.git
synced 2026-10-03 08:02:04 +00:00
20 lines
433 B
Go
20 lines
433 B
Go
package models
|
|
|
|
import "github.com/google/uuid"
|
|
|
|
// ParamUUID is a uuid bound from a query string; gin's form binding cannot set a
|
|
// bare uuid.UUID and rejects the whole request instead.
|
|
type ParamUUID struct {
|
|
uuid.UUID
|
|
}
|
|
|
|
// UnmarshalParam implements gin's binding.BindUnmarshaler.
|
|
func (p *ParamUUID) UnmarshalParam(param string) error {
|
|
id, err := uuid.Parse(param)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
p.UUID = id
|
|
return nil
|
|
}
|