rob05c commented on a change in pull request #2269: Deliveryservice_Server API 
conversion to Go
URL: 
https://github.com/apache/incubator-trafficcontrol/pull/2269#discussion_r188112182
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
 ##########
 @@ -263,7 +243,409 @@ func (dss *TODeliveryServiceServer) Delete(db *sqlx.DB, 
user auth.CurrentUser) (
        rollbackTransaction = false
        return nil, tc.NoError
 }
-func selectQuery() string {
+
+func selectQuery( orderby string, limit string, offset string) string {
+
+       selectStmt := `SELECT
+       s.deliveryService,
+       s.server,
+       s.last_updated
+       FROM deliveryservice_server s
+       ORDER BY `+ orderby +` LIMIT `+limit+` OFFSET `+offset+` ROWS`
+
+       return selectStmt
+}
+
+func deleteQuery() string {
+       query := `DELETE FROM deliveryservice_server
+       WHERE deliveryservice=:deliveryservice and server=:server`
+       return query
+}
+
+
+type DSServers struct {
+       DsId *int                                               `json:"dsId" 
db:"deliveryservice"`
+       Servers []int                                   `json:"servers"`
+       Replace *bool                                   `json:"replace"`
+}
+
+type TODSServers DSServers
+var dsserversRef = TODSServers(DSServers{})
+
+func GetServersForDsIdRef() *TODSServers {
+       return &dsserversRef
+}
+
+func GetReplaceHandler( db *sqlx.DB ) http.HandlerFunc {
+       return func(w http.ResponseWriter, r *http.Request) {
+               handleErrs := tc.GetHandleErrorsFunc(w, r)
+               ctx := r.Context()
+               user, err := auth.GetCurrentUser(ctx)
+               if err != nil {
+                       log.Errorf("unable to retrieve current user from 
context: %s", err)
 
 Review comment:
   This is leaking the body, if there's an error. Need to move `defer 
r.Body.Close()` to the top of the function.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to