Skip to content

Commit

Permalink
feat: unexport server functions used only in server pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
ingvaar committed May 10, 2022
1 parent 80ae76d commit f0c0a0e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
5 changes: 0 additions & 5 deletions cmd/start.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package cmd

import (
<<<<<<< HEAD
"net/http"

=======
"github.com/rs/zerolog/log"
>>>>>>> ce45dce (feat: move server related code to server package)
"okp4/cosmos-faucet/pkg/client"
"okp4/cosmos-faucet/pkg/server"

Expand Down
3 changes: 1 addition & 2 deletions pkg/server/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package server

import "net/http"

// NewHealthRequestHandlerFunc returns a REST handler func to check app status
func NewHealthRequestHandlerFunc() http.HandlerFunc {
func newHealthRequestHandlerFunc() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte(""))
Expand Down
5 changes: 2 additions & 3 deletions pkg/server/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var totalRequests = prometheus.NewCounterVec(

var responseStatus = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "response_status",
Name: "response_status_total",
Help: "Status of HTTP response",
},
[]string{"status"},
Expand Down Expand Up @@ -73,7 +73,6 @@ func prometheusMiddleware(handler http.Handler) http.Handler {
})
}

// NewMetricsRequestHandler returns a REST handler returning useful prometheus metrics
func NewMetricsRequestHandler() http.Handler {
func newMetricsRequestHandler() http.Handler {
return promhttp.Handler()
}
6 changes: 3 additions & 3 deletions pkg/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ func (s *httpServer) createRoutes(faucet *client.Faucet) {
s.router.Use(prometheusMiddleware)
s.router.Path("/").
Queries("address", "{address}").
HandlerFunc(NewSendRequestHandlerFn(context.Background(), faucet)).
HandlerFunc(newSendRequestHandlerFn(context.Background(), faucet)).
Methods("GET")
s.router.Path("/health").
HandlerFunc(NewHealthRequestHandlerFunc()).
HandlerFunc(newHealthRequestHandlerFunc()).
Methods("GET")
s.router.Path("/metrics").
Handler(NewMetricsRequestHandler()).
Handler(newMetricsRequestHandler()).
Methods("GET")
}
4 changes: 2 additions & 2 deletions pkg/server/send.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package server

import (
"context"
"net/http"

"okp4/cosmos-faucet/pkg/client"
Expand All @@ -10,8 +11,7 @@ import (
"github.com/rs/zerolog/log"
)

// NewSendRequestHandlerFn returns an HTTP REST handler for make transaction to a given address.
func NewSendRequestHandlerFn(faucet *client.Faucet) http.HandlerFunc {
func newSendRequestHandlerFn(ctx context.Context, faucet *client.Faucet) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
bech32Addr := vars["address"]
Expand Down

0 comments on commit f0c0a0e

Please sign in to comment.