Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/templates/README.template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img align="center" width="1048" height="512" alt="Secure Proxy for Signal REST API" src="https://github.com/CodeShellDev/secured-signal-api/raw/refs/heads/main/logo/landscape" />
<img align="center" width="1048" height="512" alt="Secure Proxy for Signal REST API" src="https://github.com/CodeShellDev/secured-signal-api/raw/refs/heads/main/logo/banner.png" />

<h3 align="center">Secure Proxy for <a href="https://github.com/bbernhard/signal-cli-rest-api">Signal Messenger REST API</a></h3>

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ RUN apk --no-cache add ca-certificates

ENV SERVER__PORT=8880

ENV DEFAULTS_PATH=/app/config/defaults.yml
ENV DEFAULTS_PATH=/app/data/defaults.yml
ENV FAVICON_PATH=/app/data/favicon.ico

ENV CONFIG_PATH=/config/config.yml
ENV TOKENS_DIR=/config/tokens
Expand Down
File renamed without changes.
Binary file added data/favicon.ico
Binary file not shown.
23 changes: 23 additions & 0 deletions internals/proxy/middlewares/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package middlewares

import (
"net/http"

"github.com/codeshelldev/secured-signal-api/utils/config"
)

type ServeMiddleware struct {
Next http.Handler
}

func (data ServeMiddleware) Use() http.Handler {
mux := http.NewServeMux()

mux.HandleFunc("/favicon.ico", func(w http.ResponseWriter, req *http.Request) {
http.ServeFile(w, req, config.ENV.FAVICON_PATH)
})

mux.Handle("/", data.Next)

return mux
}
2 changes: 1 addition & 1 deletion internals/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ func Create(targetUrl string) *httputil.ReverseProxy {
proxy := httputil.NewSingleHostReverseProxy(url)

return proxy
}
}
File renamed without changes
28 changes: 16 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
log "github.com/codeshelldev/secured-signal-api/utils/logger"
)

var initHandler *httputil.ReverseProxy
var proxy_last *httputil.ReverseProxy

var ENV *config.ENV_

Expand All @@ -31,29 +31,33 @@ func main() {

log.Info("Initialized Logger with Level of ", log.Level())

initHandler = proxy.Create(ENV.API_URL)
proxy_last = proxy.Create(ENV.API_URL)

body_m4 := middlewares.BodyMiddleware{
Next: initHandler,
body_m5 := middlewares.BodyMiddleware{
Next: proxy_last,
}

temp_m3 := middlewares.TemplateMiddleware{
Next: body_m4.Use(),
temp_m4 := middlewares.TemplateMiddleware{
Next: body_m5.Use(),
}

endp_m2 := middlewares.EndpointsMiddleware{
Next: temp_m3.Use(),
endp_m3 := middlewares.EndpointsMiddleware{
Next: temp_m4.Use(),
}

auth_m1 := middlewares.AuthMiddleware{
Next: endp_m2.Use(),
auth_m2 := middlewares.AuthMiddleware{
Next: endp_m3.Use(),
}

serv_m1 := middlewares.ServeMiddleware{
Next: auth_m2.Use(),
}

log_m0 := middlewares.LogMiddleware{
Next: auth_m1.Use(),
Next: serv_m1.Use(),
}

log.Info("Initialized Proxy Handler")
log.Info("Initialized Middlewares")

addr := "0.0.0.0:" + ENV.PORT

Expand Down
2 changes: 2 additions & 0 deletions utils/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
type ENV_ struct {
CONFIG_PATH string
DEFAULTS_PATH string
FAVICON_PATH string
TOKENS_DIR string
LOG_LEVEL string
PORT string
Expand All @@ -37,6 +38,7 @@ var ENV *ENV_ = &ENV_{
CONFIG_PATH: os.Getenv("CONFIG_PATH"),
DEFAULTS_PATH: os.Getenv("DEFAULTS_PATH"),
TOKENS_DIR: os.Getenv("TOKENS_DIR"),
FAVICON_PATH: os.Getenv("FAVICON_PATH"),
API_TOKENS: []string{},
SETTINGS: map[string]*SETTING_{

Expand Down