Refactor
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
parent
304584fc66
commit
a0cb9d8075
3 changed files with 10 additions and 5 deletions
|
|
@ -4,6 +4,8 @@ import (
|
|||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"go-api/utils"
|
||||
)
|
||||
|
||||
type ErrorResponse struct {
|
||||
|
|
@ -18,7 +20,7 @@ type SuccessResponse struct {
|
|||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("Running handler...")
|
||||
|
||||
code := getResponseCode(r)
|
||||
code := utils.GetResponseCode(r)
|
||||
|
||||
w.WriteHeader(code)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
@ -38,7 +40,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||
func main() {
|
||||
http.HandleFunc("/", handler)
|
||||
|
||||
addr := ":" + getPort()
|
||||
addr := ":" + utils.GetPort()
|
||||
|
||||
log.Printf("Starting server on %s", addr)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue