Clean up httpclient package 83/203283/1
authorjw_wonny.cha <jw_wonny.cha@samsung.com>
Thu, 11 Apr 2019 08:28:27 +0000 (17:28 +0900)
committerjw_wonny.cha <jw_wonny.cha@samsung.com>
Thu, 11 Apr 2019 08:28:27 +0000 (17:28 +0900)
Change-Id: I9d9a592bb862fe5ca92ae9b5700c1c82bf7be5d6
Signed-off-by: jw_wonny.cha <jw_wonny.cha@samsung.com>
src/common/common.go
src/restapi/httpclient/configure.go [deleted file]
src/restapi/httpclient/http_sender.go
src/restapi/httpclient/http_sender_test.go
src/restapi/httpclient/types.go [new file with mode: 0644]

index 0ed48f7911eb6ad901993eefa3ed52427e9ff1d2..1e48ccbdac184a5ac3ab617bc7a3b3979867fe8b 100755 (executable)
@@ -17,6 +17,7 @@
 package common
 
 import (
+       "log"
        "net"
        "os"
 )
@@ -53,3 +54,11 @@ func GetOutboundIP() (addr string, err error) {
        }
        return
 }
+
+func CheckError(err error) bool {
+       if err != nil {
+               log.Println(err.Error())
+               return true
+       }
+       return false
+}
diff --git a/src/restapi/httpclient/configure.go b/src/restapi/httpclient/configure.go
deleted file mode 100755 (executable)
index 5867ac9..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright 2019 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *******************************************************************************/
-package httpclient
-
-const (
-       // ConstWellknownPort is wellknonw port
-       ConstWellknownPort = 56001
-
-       // ConstLocalTarget is for knowing local environments
-       ConstLocalTarget = "localhost"
-
-       // ConstPrefixHTTP is "http://"
-       ConstPrefixHTTP = "http://"
-)
index 70fa06d73df273c805035c4e992329eb42d0c6ce..0035c1fa1cd3d65338959296b13e5c9592f252f5 100755 (executable)
@@ -1,3 +1,5 @@
+package httpclient
+
 /*******************************************************************************
  * Copyright 2019 Samsung Electronics All Rights Reserved.
  *
@@ -14,7 +16,6 @@
  * limitations under the License.
  *
  *******************************************************************************/
-package httpclient
 
 import (
        "bytes"
index 23f75b0a5e3ce966bb7777f7ef53dcfd205fc738..d2d0c29a27d8c6956f359809b908d3c684e39c3d 100755 (executable)
@@ -1,3 +1,5 @@
+package httpclient
+
 /*******************************************************************************
  * Copyright 2019 Samsung Electronics All Rights Reserved.
  *
@@ -14,7 +16,6 @@
  * limitations under the License.
  *
  *******************************************************************************/
-package httpclient
 
 import (
        "encoding/json"
@@ -29,9 +30,9 @@ import (
 var (
        server         *httptest.Server
        mockRemoteAddr string
-)
 
-var keyFilePath string = "./../../securemgr/test/key.txt"
+       keyFilePath = "./../../securemgr/test/key.txt"
+)
 
 func writeJSONResponse(w http.ResponseWriter, data []byte, status int) {
        log.Printf("[%s] writeJSONResponse: %s", "test", data)
diff --git a/src/restapi/httpclient/types.go b/src/restapi/httpclient/types.go
new file mode 100644 (file)
index 0000000..af28d84
--- /dev/null
@@ -0,0 +1,42 @@
+package httpclient
+
+/*******************************************************************************
+ * Copyright 2019 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************/
+
+var (
+       logPrefix = "httpclient"
+)
+
+const (
+       // ConstWellknownPort is wellknonw port
+       ConstWellknownPort = 56001
+
+       // ConstLocalTarget is for knowing local environments
+       ConstLocalTarget = "localhost"
+
+       // ConstPrefixHTTP is "http://"
+       ConstPrefixHTTP = "http://"
+
+       // ConstServiceExecuteURI is URI for creating & executing service
+       ConstServiceExecuteURI = "/api/v1/servicemgr/services"
+
+       // ConstGetScoreURI is URI for getting score value
+       ConstGetScoreURI = "/api/v1/scoringmgr/score/"
+
+       // ConstServiceStatusNotiURI is URI for notification status of service
+       ConstServiceStatusNotiURI = "/api/v1/servicemgr/services/notification/"
+)