-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ale8k
committed
Nov 27, 2021
1 parent
2319e54
commit ce44c15
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package handlers | ||
|
||
import ( | ||
"net/http" | ||
) | ||
|
||
func GetServerHealth(resp http.ResponseWriter, req http.Request) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,45 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
var Handler *http.ServeMux | ||
|
||
func logg(h http.Handler) http.Handler { | ||
return http.HandlerFunc( | ||
func(w http.ResponseWriter, r *http.Request) { | ||
fmt.Println("Before") | ||
h.ServeHTTP(w, r) // call original | ||
fmt.Println("After") | ||
}) | ||
} | ||
|
||
func StartServer() { | ||
k := logg(nil) | ||
fmt.Println(k) | ||
Handler := http.NewServeMux() | ||
|
||
// type HandlerFunc func(ResponseWriter, *Request) | ||
// internal mux call just casts our func to this ^ | ||
// func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request)) { | ||
// if handler == nil { | ||
// panic("http: nil handler") | ||
// } | ||
// mux.Handle(pattern, HandlerFunc(handler)) | ||
// } | ||
|
||
// type Handler interface { | ||
// ServeHTTP(ResponseWriter, *Request) | ||
// } | ||
|
||
server := &http.Server{ | ||
Addr: ":9000", | ||
Handler: nil, | ||
Handler: Handler, | ||
} | ||
|
||
log.Println("Starting server on port 9000...") | ||
log.Fatalf("Server failed to start: %v", server.ListenAndServe()) | ||
} |