get very simple webserver up and running
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
this is meant to be a reusable webserver component that I can integrate into applications
|
||||
while it can serve custom routes it is also designed to server routes that are needed in all of my applications
|
||||
Examples:
|
||||
- Login page
|
||||
@@ -5,9 +5,13 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ServeWebpage(url string, handler func(http.ResponseWriter, *http.Request)) {
|
||||
http.HandleFunc(url, handler)
|
||||
}
|
||||
|
||||
func ServeWebserver() {
|
||||
err := http.ListenAndServe(":8080", nil)
|
||||
if err != nil {
|
||||
fmt.Printf(err.Error())
|
||||
fmt.Print(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user