-
Notifications
You must be signed in to change notification settings - Fork 6
/
redirect_builder.go
62 lines (53 loc) · 1.73 KB
/
redirect_builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
// Autogenerated by buildergenerator
package goexoml
import (
"errors"
)
var _ = errors.New("_")
// SetMethod sets Method for Redirect struct instance
func (redirectReceiver *Redirect) SetMethod(method string) *Redirect {
redirectReceiver.Method = method
return redirectReceiver
}
// SetURL sets URL for Redirect struct instance
func (redirectReceiver *Redirect) SetURL(url string) *Redirect {
redirectReceiver.URL = url
return redirectReceiver
}
// Setter returns setter function for the field given
func (redirectReceiver *Redirect) Setter(field string) (setter func(interface{}) (*Redirect, error)) {
switch field {
case "Method":
setter = func(MethodField interface{}) (*Redirect, error) {
if MethodValue, ok := MethodField.(string); ok {
return redirectReceiver.SetMethod(MethodValue), nil
}
return nil, errors.New("Invalid type Expected string ")
}
case "URL":
setter = func(URLField interface{}) (*Redirect, error) {
if URLValue, ok := URLField.(string); ok {
return redirectReceiver.SetURL(URLValue), nil
}
return nil, errors.New("Invalid type Expected string ")
}
}
return
}
// NewRedirect return a new Redirect pointer
func NewRedirect() *Redirect {
return new(Redirect)
}
// IRedirect The interface that satisfies all the methods for this struct
// IRedirect asserts implementation of setters for all the fields of Redirect
type IRedirect interface {
SetMethod(method string) *Redirect
SetURL(url string) *Redirect
Setter(string) func(interface{}) (*Redirect, error)
}
// AddRedirect appends the verb to response
func (r *Response) AddRedirect(redirect IRedirect) *Response {
r.Response = append(r.Response, redirect)
return r
}