Skip to content

Commit

Permalink
added sms response format
Browse files Browse the repository at this point in the history
  • Loading branch information
briandoesdev committed Jun 23, 2024
1 parent cc1e7a0 commit 1b09731
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion routes/lookup/lookup_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Route(e *echo.Echo) {

func getNumberSummary(c echo.Context) error {
var sum string
f := c.Request().Header.Get("X-Response-Format")
f := c.Request().Header.Get("X-Custom-Format")
number := c.FormValue("number")

if number == "" {
Expand All @@ -42,6 +42,8 @@ func getNumberSummary(c echo.Context) error {
switch f {
case "api":
return c.JSON(500, &routes.ErrorPayload{Message: err.Error()})
case "sms":
return c.String(200, err.Error())
default:
return c.Render(200, "home.html", map[string]interface{}{"sum": err.Error()})
}
Expand All @@ -53,6 +55,8 @@ func getNumberSummary(c echo.Context) error {
switch f {
case "api":
return c.JSON(500, &routes.ErrorPayload{Message: err.Error()})
case "sms":
return c.String(200, sum)
default:
return c.Render(200, "home.html", map[string]interface{}{"sum": err.Error()})
}
Expand All @@ -61,6 +65,8 @@ func getNumberSummary(c echo.Context) error {
switch f {
case "api":
return c.JSON(200, &Data{PhoneNumber: number, Summary: sum})
case "sms":
return c.String(200, sum)
default:
return c.Render(200, "home.html", map[string]interface{}{"sum": sum})
}
Expand Down

0 comments on commit 1b09731

Please sign in to comment.