add start server method

This commit is contained in:
Ruidy 2022-06-02 18:36:26 +02:00
parent e598ac2c09
commit 1458d55d32
4 changed files with 7 additions and 5 deletions

View file

@ -32,3 +32,7 @@ func NewServer() *Server {
func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.Router.ServeHTTP(w, r)
}
func (s Server) Start(port string) error {
return http.ListenAndServe(port, s)
}

View file

@ -18,7 +18,7 @@
"prettier": "^2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"react-scripts": "^5.0.0",
"typescript": "^4.5.4",
"web-vitals": "^2.1.3"
}

View file

@ -13,7 +13,7 @@
"prettier": "^2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"react-scripts": "^5.0.0",
"typescript": "^4.5.4",
"web-vitals": "^2.1.3"
},

View file

@ -3,7 +3,6 @@ package main
import (
"flag"
"log"
"net/http"
"github.com/rjNemo/go-pass-gen/api"
"github.com/rjNemo/go-pass-gen/cmd"
@ -25,6 +24,5 @@ func cli() {
}
func serveWeb() {
s := api.NewServer()
log.Fatal(http.ListenAndServe(":8080", s))
log.Fatal(api.NewServer().Start(":8080"))
}