File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ func newMetaField(rf reflect.StructField) (*Meta, error) {
168
168
169
169
var (
170
170
timeType = reflect .TypeOf (time.Time {})
171
- urlType = reflect .TypeOf ((* url .URL )(nil )). Elem ()
171
+ urlType = reflect .TypeOf ((* url .URL )(nil ))
172
172
durationType = reflect .TypeOf (time .Duration (0 ))
173
173
)
174
174
@@ -219,8 +219,16 @@ func setValue(rv reflect.Value, str string) error {
219
219
case reflect .String :
220
220
// String
221
221
rv .SetString (str )
222
+ case reflect .Ptr :
223
+ if rv .Type () == urlType {
224
+ if v , err := url .Parse (str ); err == nil {
225
+ rv .Set (reflect .ValueOf (v ))
226
+ return nil
227
+ }
228
+ }
229
+ fallthrough
222
230
default :
223
- // TODO URL and Datetime
231
+ // TODO: Datetime
224
232
return httpresponse .ErrBadRequest .Withf ("invalid value for %s: %q" , rv .Type (), str )
225
233
}
226
234
@@ -254,10 +262,11 @@ func typeName(rt reflect.Type) string {
254
262
if subtype := typeName (rt .Elem ()); subtype != "" && rt .Key ().Kind () == reflect .String {
255
263
return "map(" + subtype + ")"
256
264
}
257
- case reflect .Struct :
265
+ case reflect .Ptr :
258
266
if rt == urlType {
259
267
return "url"
260
268
}
269
+ case reflect .Struct :
261
270
if rt == timeType {
262
271
return "datetime"
263
272
}
You can’t perform that action at this time.
0 commit comments