Skip to content

Commit fe4fb2c

Browse files
committed
Merge remote-tracking branch 'origin/switchToGin' into develop
2 parents 4c8776d + c6f501d commit fe4fb2c

24 files changed

Lines changed: 100853 additions & 277 deletions

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ COPY "go.mod" ./"go.mod"
2828
COPY "go.sum" ./"go.sum"
2929
COPY keyfile ./keyfile
3030
COPY "main.go" ./"main.go"
31+
COPY "main_defs.go" ./"main_defs.go"
3132
COPY "config_docker_w_redis.json" ./"config_docker_w_redis.json"
3233
COPY tools/"create_wissance_demo_users_docker.sh" ./"create_wissance_demo_users_docker.sh"
3334
COPY tools/"docker_app_runner.sh" ./"docker_app_runner.sh"

api/rest/common.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package rest
22

33
import (
44
"encoding/json"
5-
"net/http"
5+
"github.com/gin-gonic/gin"
66
)
77

88
const (
@@ -19,23 +19,23 @@ const (
1919
// beforeHandle
2020
/* This function prepare response headers prior to response handle. It sets content-type and CORS headers.
2121
* Parameters:
22-
* - respWriter - gorilla/mux response writer
22+
* - respWriter - gin response writer
2323
* Returns nothing
2424
*/
25-
func beforeHandle(respWriter *http.ResponseWriter) {
25+
func beforeHandle(respWriter *gin.ResponseWriter) {
2626
(*respWriter).Header().Set("Content-Type", "application/json")
2727
(*respWriter).Header().Set("Accept", "application/json")
2828
}
2929

3030
// afterHandle
3131
/* This function finalize response handle: serialize (json) and write object and set status code. If error occur during object serialization status code sets to 500
3232
* Parameters:
33-
* - respWriter - gorilla/mux response writer
33+
* - respWriter - gin response writer
3434
* - statusCode - http response status
3535
* - data - object (json) could be empty
3636
* Returns nothing
3737
*/
38-
func afterHandle(respWriter *http.ResponseWriter, statusCode int, data interface{}) {
38+
func afterHandle(respWriter *gin.ResponseWriter, statusCode int, data interface{}) {
3939
(*respWriter).WriteHeader(statusCode)
4040
if data != nil {
4141
err := json.NewEncoder(*respWriter).Encode(data)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package metrics
2+
3+
import (
4+
"github.com/gin-gonic/gin"
5+
"github.com/prometheus/client_golang/prometheus/promhttp"
6+
)
7+
8+
func GetPrometheusHandler() gin.HandlerFunc {
9+
h := promhttp.Handler()
10+
11+
return func(c *gin.Context) {
12+
h.ServeHTTP(c.Writer, c.Request)
13+
}
14+
}

api/rest/utilities.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"unicode"
55
)
66

7-
// Checks that the string consists of allowed characters.
7+
// Validate function that checks that whether a string consists of allowed characters or not
88
func Validate(str string) bool {
99
if str == "" {
1010
return false

0 commit comments

Comments
 (0)