Refactored the code some more

This commit is contained in:
phoenix
2025-10-22 22:54:25 -04:00
parent 3336efff95
commit b1352d56fe
4 changed files with 21 additions and 8 deletions
+2 -7
View File
@@ -7,17 +7,12 @@ import "net/http"
import "git.kundeng.us/phoenix/textsender-api/internal/config"
import "git.kundeng.us/phoenix/textsender-api/internal/handler"
type MessageItem struct {
Id int `json:"id"`
Message string `json:"message"`
}
func main() {
fmt.Println("textsender-api")
fmt.Println(config.APP_NAME)
http.HandleFunc(handler.MESSAGE_DRAFT_ENDPOINT, handler.DraftMessageHandler)
log.Println("Starting server", config.PORT)
log.Fatal(http.ListenAndServe(":8080", nil))
log.Fatal(http.ListenAndServe(config.PortString(), nil))
}
+10
View File
@@ -1,3 +1,13 @@
package config
import "fmt"
const PORT = 8080
const APP_NAME = "textsender-api"
func PortString() string {
portMessage := fmt.Sprintf(":%d", PORT)
return portMessage
}
+3 -1
View File
@@ -2,8 +2,10 @@ package handler
import "net/http"
import "git.kundeng.us/phoenix/textsender-api/internal/model"
func DraftMessageHandler(w http.ResponseWriter, r *http.Request) {
da := MessageItem{
da := model.MessageItem{
Id: 1,
Message: "The Word",
}
+6
View File
@@ -0,0 +1,6 @@
package model
type MessageItem struct {
Id int `json:"id"`
Message string `json:"message"`
}