apps endpoint

This commit is contained in:
Ross Trottier 2024-08-22 13:53:27 -06:00
parent 54052434b4
commit 74b542023f
2 changed files with 15 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"encoding/json"
"net/http"
)
@ -23,3 +24,16 @@ func (app *application) notFound(writer http.ResponseWriter, request *http.Reque
func (app *application) vpn(writer http.ResponseWriter, request *http.Request) {
app.render(writer, request, http.StatusOK, "vpn.tmpl.html", templateData{})
}
func (app *application) appList(writer http.ResponseWriter, request *http.Request) {
appLinks := getAppLinks(app.tier, app.domain)
writer.Header().Set("Content-Type", "application/json")
data, err := json.Marshal(appLinks)
if err != nil {
app.serverError(writer, request, err)
return
}
writer.Write(data)
}

View File

@ -11,6 +11,7 @@ func (app *application) routes() *http.ServeMux {
mux.HandleFunc("GET /{$}", app.home)
mux.HandleFunc("GET /", app.notFound)
mux.HandleFunc("GET /vpn/{$}", app.vpn)
mux.HandleFunc("GET /apps/{$}", app.appList)
return mux
}