Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Add folder structure

Acho Arnold8b1dad2eaca5
diff --git a/api/.air.toml b/api/.air.toml
new file mode 100644
index 00000000..15d45a05
--- /dev/null
+++ b/api/.air.toml
@@ -0,0 +1,36 @@
+root = "."
+testdata_dir = "testdata"
+tmp_dir = "tmp"
+
+[build]
+ bin = "tmp\\main.exe"
+ cmd = "go build -o ./tmp/main.exe ."
+ delay = 1000
+ exclude_dir = ["assets", "tmp", "vendor", "testdata"]
+ exclude_file = []
+ exclude_regex = ["_test.go"]
+ exclude_unchanged = false
+ follow_symlink = false
+ full_bin = ""
+ include_dir = []
+ include_ext = ["go", "tpl", "tmpl", "html"]
+ kill_delay = "0s"
+ log = "build-errors.log"
+ send_interrupt = false
+ stop_on_error = true
+
+[color]
+ app = ""
+ build = "yellow"
+ main = "magenta"
+ runner = "green"
+ watcher = "cyan"
+
+[log]
+ time = false
+
+[misc]
+ clean_on_exit = false
+
+[screen]
+ clear_on_rebuild = false
diff --git a/api/.gitignore b/api/.gitignore
index dc545ba8..73d4e2ad 100644
--- a/api/.gitignore
+++ b/api/.gitignore
@@ -1,3 +1,4 @@
docs
.env
*main.exe
+tmp
diff --git a/api/go.mod b/api/go.mod
index 71776572..f41c7075 100644
--- a/api/go.mod
+++ b/api/go.mod
@@ -8,7 +8,9 @@ require (
github.com/gofiber/fiber/v2 v2.34.0
github.com/gofiber/swagger v0.0.1
github.com/joho/godotenv v1.4.0
+ github.com/rs/zerolog v1.26.1
github.com/swaggo/swag v1.8.2
+ go.opentelemetry.io/otel v1.7.0
)
require (
@@ -27,6 +29,7 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.37.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
+ go.opentelemetry.io/otel/trace v1.7.0 // indirect
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/tools v0.1.10 // indirect
diff --git a/api/go.sum b/api/go.sum
index abbc1a11..ec9dbb01 100644
--- a/api/go.sum
+++ b/api/go.sum
@@ -10,6 +10,7 @@ github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -19,6 +20,9 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
+github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
+github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
@@ -34,11 +38,14 @@ github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrK
github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
+github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofiber/fiber/v2 v2.32.0/go.mod h1:CMy5ZLiXkn6qwthrl03YMyW1NLfj0rhxz2LKl4t7ZTY=
github.com/gofiber/fiber/v2 v2.34.0 h1:96BJMw6uaxQhJsHY54SFGOtGgp9pgombK5Hbi4JSEQA=
github.com/gofiber/fiber/v2 v2.34.0/go.mod h1:ozRQfS+D7EL1+hMH+gutku0kfx1wLX4hAxDCtDzpj4U=
github.com/gofiber/swagger v0.0.1 h1:Qwt6uehJffeMG7zla3ampguOPtAW5K4xDAmpaL1qwXk=
github.com/gofiber/swagger v0.0.1/go.mod h1:gal49FHSULvKAl9Ta+W7fRHdlTWhHPvArmsxKaIdLw4=
+github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
+github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
@@ -68,8 +75,12 @@ github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJ
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
+github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc=
+github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
@@ -77,8 +88,9 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2 h1:+iNTcqQJy0OZ5jk6a5NLib47eqXK8uYcPX+O4+cBpEM=
github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w=
github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ=
@@ -93,14 +105,20 @@ github.com/valyala/fasthttp v1.37.0/go.mod h1:t/G+3rLek+CyY9bnIE+YlMRddxVAAGjhxn
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM=
+go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk=
+go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o=
+go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
@@ -123,6 +141,7 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
@@ -134,6 +153,7 @@ golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/api/main.go b/api/main.go
index cb6ab0d7..f266a90b 100644
--- a/api/main.go
+++ b/api/main.go
@@ -3,28 +3,36 @@ package main
import (
"log"
+ "github.com/NdoleStudio/http-sms-manager/pkg/di"
+
_ "github.com/NdoleStudio/http-sms-manager/docs"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/swagger"
)
-// @title HTTP SMS API
-// @version 1.0
-// @description Sample API to send messages using android sms manager via HTTP
-// @termsOfService http://swagger.io/terms/
-// @contact.name HTTP SMS Support
+// @title HTTP SMS API
+// @version 1.0
+// @description API to send SMS messages using android [SmsManager](https://developer.android.com/reference/android/telephony/SmsManager) via HTTP
+//
+// @contact.name HTTP SMS Support
// @contact.email [email protected]
-// @license.name Apache 2.0
-// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
-// @host api.httpsms.com
-// @BasePath /
+//
+// @license.name MIT
+// @license.url https://raw.githubusercontent.com/NdoleStudio/http-sms-manager/main/LICENSE
+//
+// @host api.httpsms.com
+// @BasePath /v1
func main() {
app := fiber.New()
- // log requests/responses
app.Use(logger.New())
+ container := di.NewContainer()
+
+ apiV1 := app.Group("v1")
+ apiV1.Post("/messages/send", container.MessageHandler().Send)
+
app.Get("/*", swagger.HandlerDefault)
log.Println(app.Listen(":8000"))
diff --git a/api/pkg/di/container.go b/api/pkg/di/container.go
new file mode 100644
index 00000000..0324224a
--- /dev/null
+++ b/api/pkg/di/container.go
@@ -0,0 +1,56 @@
+package di
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/NdoleStudio/http-sms-manager/pkg/handlers"
+ "github.com/NdoleStudio/http-sms-manager/pkg/telemetry"
+ "github.com/gofiber/fiber/v2"
+ "github.com/rs/zerolog"
+)
+
+// Container is used to resolve services at runtime
+type Container struct {
+ logger telemetry.Logger
+ messageHandler *handlers.MessageHandler
+}
+
+// NewContainer creates a new dependency injection container
+func NewContainer() (container *Container) {
+ return &Container{
+ logger: logger().WithService(fmt.Sprintf("%T", container)),
+ }
+}
+
+// Logger creates a new instance of telemetry.Logger
+func (container Container) Logger() (l telemetry.Logger) {
+ container.logger.Debug(fmt.Sprintf("creating %T", l))
+ return logger()
+}
+
+// MessageHandler creates a new instance of handlers.MessageHandler
+func (container *Container) MessageHandler() (handler *handlers.MessageHandler) {
+ if container.messageHandler != nil {
+ return container.messageHandler
+ }
+
+ container.logger.Debug(fmt.Sprintf("creating %T", handler))
+
+ return handlers.NewMessageHandler()
+}
+
+func logger() telemetry.Logger {
+ hostname, _ := os.Hostname()
+ fields := fiber.Map{
+ "pid": os.Getpid(),
+ "hostname": hostname,
+ }
+ return telemetry.NewZerologLogger(
+ zerolog.New(
+ zerolog.ConsoleWriter{
+ Out: os.Stderr,
+ },
+ ).With().Fields(fields).Timestamp().CallerWithSkipFrameCount(3),
+ )
+}
diff --git a/api/pkg/entities/message.go b/api/pkg/entities/message.go
new file mode 100644
index 00000000..5fde42f1
--- /dev/null
+++ b/api/pkg/entities/message.go
@@ -0,0 +1,4 @@
+package entities
+
+// Message represents a message sent between 2 users
+type Message struct{}
diff --git a/api/pkg/events/event_dispatcher.go b/api/pkg/events/event_dispatcher.go
new file mode 100644
index 00000000..b3adf695
--- /dev/null
+++ b/api/pkg/events/event_dispatcher.go
@@ -0,0 +1 @@
+package events
diff --git a/api/pkg/handlers/handler.go b/api/pkg/handlers/handler.go
new file mode 100644
index 00000000..a4c23c8c
--- /dev/null
+++ b/api/pkg/handlers/handler.go
@@ -0,0 +1,58 @@
+package handlers
+
+import (
+ "net/url"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+// handler is the base struct for handling requests
+type handler struct{}
+
+func (h *handler) responseBadRequest(c *fiber.Ctx, payload any) error {
+ return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
+ "status": "error",
+ "message": "The request isn't properly formed",
+ "data": payload,
+ })
+}
+
+func (h *handler) responseInternalServerError(c *fiber.Ctx) error {
+ return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
+ "status": "error",
+ "message": "We ran into an internal error while handling the request.",
+ "data": nil,
+ })
+}
+
+func (h *handler) responseForbidden(c *fiber.Ctx) error {
+ return c.Status(fiber.StatusForbidden).JSON(fiber.Map{
+ "status": "error",
+ "message": fiber.ErrForbidden.Message,
+ "data": nil,
+ })
+}
+
+func (h *handler) responseUnprocessableEntity(c *fiber.Ctx, errors url.Values, message string) error {
+ return c.Status(fiber.StatusUnprocessableEntity).JSON(fiber.Map{
+ "status": "error",
+ "message": message,
+ "data": errors,
+ })
+}
+
+func (h *handler) responseNotFound(c *fiber.Ctx, message string) error {
+ return c.Status(fiber.StatusNotFound).JSON(fiber.Map{
+ "status": "error",
+ "message": message,
+ "data": nil,
+ })
+}
+
+func (h *handler) responseOK(c *fiber.Ctx, message string, data interface{}) error {
+ return c.Status(fiber.StatusOK).JSON(fiber.Map{
+ "status": "success",
+ "message": message,
+ "data": data,
+ })
+}
diff --git a/api/pkg/handlers/message_handler.go b/api/pkg/handlers/message_handler.go
new file mode 100644
index 00000000..c2c21d28
--- /dev/null
+++ b/api/pkg/handlers/message_handler.go
@@ -0,0 +1,25 @@
+package handlers
+
+import "github.com/gofiber/fiber/v2"
+
+// MessageHandler handles message http requests.
+type MessageHandler struct {
+ handler
+}
+
+// NewMessageHandler creates a new MessageHandler
+func NewMessageHandler() *MessageHandler {
+ return &MessageHandler{}
+}
+
+// Send a new entities.Message
+// @Summary Send a new SMS message
+// @Description Add a new SMS message to be sent by the android phone
+// @Tags Messages
+// @Accept json
+// @Produce json
+// @Success 200 {object} responses.MessageResponse
+// @Router /messages/send [post]
+func (handler *MessageHandler) Send(c *fiber.Ctx) error {
+ return nil
+}
diff --git a/api/pkg/responses/message_response.go b/api/pkg/responses/message_response.go
new file mode 100644
index 00000000..981ea145
--- /dev/null
+++ b/api/pkg/responses/message_response.go
@@ -0,0 +1,9 @@
+package responses
+
+import "github.com/NdoleStudio/http-sms-manager/pkg/entities"
+
+// MessageResponse is the payload containing an entities.Message
+type MessageResponse struct {
+ response
+ Data entities.Message `json:"data"`
+}
diff --git a/api/pkg/responses/response.go b/api/pkg/responses/response.go
new file mode 100644
index 00000000..2a9d7156
--- /dev/null
+++ b/api/pkg/responses/response.go
@@ -0,0 +1,6 @@
+package responses
+
+type response struct {
+ Status string `json:"status" example:"success"`
+ Message string `json:"message" example:"item created successfully"`
+}
diff --git a/api/pkg/services/message_service.go b/api/pkg/services/message_service.go
new file mode 100644
index 00000000..5e568ea8
--- /dev/null
+++ b/api/pkg/services/message_service.go
@@ -0,0 +1 @@
+package services
diff --git a/api/pkg/telemetry/logger.go b/api/pkg/telemetry/logger.go
new file mode 100644
index 00000000..ae8a9273
--- /dev/null
+++ b/api/pkg/telemetry/logger.go
@@ -0,0 +1,25 @@
+package telemetry
+
+// Logger is an interface for creating customer logger implementations
+type Logger interface {
+ // Error logs an error
+ Error(err error)
+
+ // WithService creates a new structured logger instance with a service name
+ WithService(string) Logger
+
+ // WithString creates a new structured logger instance with a key value pair
+ WithString(key string, value string) Logger
+
+ // Info logs a new message with information level.
+ Info(value string)
+
+ // Warn logs a new message with warning level.
+ Warn(value string)
+
+ // Trace logs a new message with trace level.
+ Trace(value string)
+
+ // Debug logs a new message with debug level.
+ Debug(value string)
+}
diff --git a/api/pkg/telemetry/zerolog_logger.go b/api/pkg/telemetry/zerolog_logger.go
new file mode 100644
index 00000000..ac6ec814
--- /dev/null
+++ b/api/pkg/telemetry/zerolog_logger.go
@@ -0,0 +1,54 @@
+package telemetry
+
+import (
+ "github.com/rs/zerolog"
+ semconv "go.opentelemetry.io/otel/semconv/v1.10.0"
+)
+
+type zerologLogger struct {
+ zerolog zerolog.Logger
+ writers zerolog.LevelWriter
+ context zerolog.Context
+}
+
+// NewZerologLogger creates a new instance of the zerolog logger
+func NewZerologLogger(ctx zerolog.Context) Logger {
+ return &zerologLogger{
+ zerolog: ctx.Logger(),
+ }
+}
+
+// WithService creates a new structured zerolog logger instance with a service name
+func (logger *zerologLogger) WithService(service string) Logger {
+ return NewZerologLogger(logger.zerolog.With().Str(string(semconv.ServiceNameKey), service))
+}
+
+// Info logs a new message with information level.
+func (logger *zerologLogger) Info(value string) {
+ logger.zerolog.Info().Msg(value)
+}
+
+// Warn logs a new message with warning level.
+func (logger *zerologLogger) Warn(value string) {
+ logger.zerolog.Warn().Msg(value)
+}
+
+// Trace logs a new message with trace level.
+func (logger *zerologLogger) Trace(value string) {
+ logger.zerolog.Trace().Msg(value)
+}
+
+// Debug logs a new message with debug level.
+func (logger *zerologLogger) Debug(value string) {
+ logger.zerolog.Debug().Msg(value)
+}
+
+// Error logs an error
+func (logger *zerologLogger) Error(err error) {
+ logger.zerolog.Error().Err(err).Send()
+}
+
+// WithString creates a new structured logger instance with a key value pair
+func (logger *zerologLogger) WithString(key string, value string) Logger {
+ return NewZerologLogger(logger.zerolog.With().Str(key, value))
+}