Skip to content

Commit

Permalink
Adds const
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivrij committed May 15, 2023
1 parent 708d0c2 commit f4ecbe3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func InitRoutes(loader *models.Loader) *mux.Router {
Data: loader,
}

serveMux.HandleFunc("/api/v1/health", middleware.Adapt(v1Handler.Health, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders()))
serveMux.HandleFunc("/api/v1/health", middleware.Adapt(v1Handler.Health, middleware.ValidateRestMethod("GET"), middleware.SetCorsHeaders()))

//resultaten
serveMux.HandleFunc("/api/v1/resultaten", middleware.Adapt(v1Handler.ListResultaten, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders()))
Expand Down
7 changes: 7 additions & 0 deletions api/v1/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package v1

const (
productionHostName string = "referentielijsten-api.vng.cloud"
// currently we do not have a test server but this is for future proofing
testHostName string = "referentielijsten-api.test.vng.cloud"
)
11 changes: 3 additions & 8 deletions api/v1/resultaat.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func (r *ReferentielijstenHandler) ListResultaten(w http.ResponseWriter, req *ht
// 404: Fout
// 405: Fout

scheme := "https://"
if req.TLS == nil {
scheme = "http://"
scheme := "http://"
if req.TLS != nil || req.Host == productionHostName || req.Host == testHostName {
scheme = "https://"
}

log.Printf("req.TLS: %v", req.TLS)
Expand Down Expand Up @@ -148,11 +148,6 @@ func (r *ReferentielijstenHandler) ListResultaten(w http.ResponseWriter, req *ht

resultsToBeUsed := r.Data.Resultaten[start:finish]

log.Printf("scheme: %v", scheme)
log.Printf("req.Host: %v", req.Host)
log.Printf("req.URL.Path: %v", req.URL.Path)
log.Printf("req.Proto: %v", req.Proto)

for _, result := range resultsToBeUsed {
u, _ := url.JoinPath(scheme, req.Host, req.URL.Path, result.URL)
result.URL = u
Expand Down

0 comments on commit f4ecbe3

Please sign in to comment.