@@ -4,11 +4,11 @@ import (
4
4
"bytes"
5
5
"context"
6
6
"encoding/json"
7
- "fmt"
8
- "github.com/inverse-inc/packetfence/go/ntlm"
9
- "github.com/julienschmidt/httprouter"
10
7
"net/http"
11
8
"os"
9
+
10
+ "github.com/inverse-inc/packetfence/go/ntlm"
11
+ "github.com/julienschmidt/httprouter"
12
12
)
13
13
14
14
type PasswordChangeEvent struct {
@@ -42,7 +42,7 @@ func (h APIHandler) eventReport(w http.ResponseWriter, r *http.Request, p httpro
42
42
Message : "Unable to connect to pfconfig service" ,
43
43
}
44
44
j , _ := json .Marshal (res )
45
- fmt . Fprintf ( w , string ( j ) )
45
+ w . Write ( j )
46
46
return
47
47
}
48
48
@@ -57,7 +57,7 @@ func (h APIHandler) eventReport(w http.ResponseWriter, r *http.Request, p httpro
57
57
Message : "Unknown payload format, expected Domain and Events JSON" ,
58
58
}
59
59
j , _ := json .Marshal (res )
60
- fmt . Fprintf ( w , string ( j ) )
60
+ w . Write ( j )
61
61
return
62
62
}
63
63
@@ -76,7 +76,7 @@ func (h APIHandler) eventReport(w http.ResponseWriter, r *http.Request, p httpro
76
76
Message : "Unknown domain " + req .Domain + ", record not found" ,
77
77
}
78
78
j , _ := json .Marshal (res )
79
- fmt . Fprintf ( w , string ( j ) )
79
+ w . Write ( j )
80
80
return
81
81
}
82
82
@@ -88,7 +88,7 @@ func (h APIHandler) eventReport(w http.ResponseWriter, r *http.Request, p httpro
88
88
Message : "Unable to find listening port for domain " + req .Domain ,
89
89
}
90
90
j , _ := json .Marshal (res )
91
- fmt . Fprintf ( w , string ( j ) )
91
+ w . Write ( j )
92
92
return
93
93
}
94
94
@@ -100,7 +100,7 @@ func (h APIHandler) eventReport(w http.ResponseWriter, r *http.Request, p httpro
100
100
Message : err .Error (),
101
101
}
102
102
j , _ := json .Marshal (res )
103
- fmt . Fprintf ( w , string ( j ) )
103
+ w . Write ( j )
104
104
return
105
105
}
106
106
@@ -110,8 +110,7 @@ func (h APIHandler) eventReport(w http.ResponseWriter, r *http.Request, p httpro
110
110
Message : "Event reported" ,
111
111
}
112
112
j , _ := json .Marshal (res )
113
- fmt .Fprintf (w , string (j ))
114
-
113
+ w .Write (j )
115
114
}
116
115
117
116
func (h APIHandler ) ntlmTest (w http.ResponseWriter , r * http.Request , p httprouter.Params ) {
@@ -134,7 +133,7 @@ func (h APIHandler) ntlmTest(w http.ResponseWriter, r *http.Request, p httproute
134
133
Message : "Unable to connect to pfconfig service" ,
135
134
}
136
135
j , _ := json .Marshal (res )
137
- fmt . Fprintf ( w , string ( j ) )
136
+ w . Write ( j )
138
137
return
139
138
}
140
139
@@ -149,7 +148,7 @@ func (h APIHandler) ntlmTest(w http.ResponseWriter, r *http.Request, p httproute
149
148
Message : "Unknown payload format, expected JSON format with id and password" ,
150
149
}
151
150
j , _ := json .Marshal (res )
152
- fmt . Fprintf ( w , string ( j ) )
151
+ w . Write ( j )
153
152
return
154
153
}
155
154
@@ -168,7 +167,7 @@ func (h APIHandler) ntlmTest(w http.ResponseWriter, r *http.Request, p httproute
168
167
Message : "Unknown domain " + req .Id + ", record not found" ,
169
168
}
170
169
j , _ := json .Marshal (res )
171
- fmt . Fprintf ( w , string ( j ) )
170
+ w . Write ( j )
172
171
return
173
172
}
174
173
@@ -180,7 +179,7 @@ func (h APIHandler) ntlmTest(w http.ResponseWriter, r *http.Request, p httproute
180
179
Message : "Unable to find listening port for domain " + req .Id ,
181
180
}
182
181
j , _ := json .Marshal (res )
183
- fmt . Fprintf ( w , string ( j ) )
182
+ w . Write ( j )
184
183
return
185
184
}
186
185
@@ -192,7 +191,7 @@ func (h APIHandler) ntlmTest(w http.ResponseWriter, r *http.Request, p httproute
192
191
Message : err .Error (),
193
192
}
194
193
j , _ := json .Marshal (res )
195
- fmt . Fprintf ( w , string ( j ) )
194
+ w . Write ( j )
196
195
return
197
196
}
198
197
@@ -203,7 +202,7 @@ func (h APIHandler) ntlmTest(w http.ResponseWriter, r *http.Request, p httproute
203
202
Message : "Machine account check failed" ,
204
203
}
205
204
j , _ := json .Marshal (res )
206
- fmt . Fprintf ( w , string ( j ) )
205
+ w . Write ( j )
207
206
return
208
207
}
209
208
@@ -213,6 +212,5 @@ func (h APIHandler) ntlmTest(w http.ResponseWriter, r *http.Request, p httproute
213
212
Message : "Machine account test OK" ,
214
213
}
215
214
j , _ := json .Marshal (res )
216
- fmt .Fprintf (w , string (j ))
217
-
215
+ w .Write (j )
218
216
}
0 commit comments