aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/routes.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-08-24 22:25:40 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-08-24 22:25:40 -0400
commit0fc3eda77004f41c5f0a804028da2d90b0373ea7 (patch)
treeedf6d74e6a2b7140350eab1e40d0fbf70e10f87c /cmd/web/routes.go
parentf4fcd237b2d0eb950fc15a8af1fb0894b6ad6359 (diff)
downloadsteam-export-0fc3eda77004f41c5f0a804028da2d90b0373ea7.tar.gz
steam-export-0fc3eda77004f41c5f0a804028da2d90b0373ea7.tar.xz
Another development snapshot. Updated license. Added Swagger documentation--embedded! Note about 'swaggo'
Diffstat (limited to 'cmd/web/routes.go')
-rw-r--r--cmd/web/routes.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/cmd/web/routes.go b/cmd/web/routes.go
index 52ae5d9..b907ab6 100644
--- a/cmd/web/routes.go
+++ b/cmd/web/routes.go
@@ -4,11 +4,22 @@ import (
"net/http"
"github.com/gorilla/mux"
+ httpSwagger "github.com/swaggo/http-swagger"
+ _ "riedstra.dev/mitch/steam-export/cmd/web/docs"
)
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
rtr := mux.NewRouter()
+ rtr.PathPrefix("/swagger").Methods("GET").Handler(
+ httpSwagger.Handler(
+ //The url pointing to API definition
+ httpSwagger.URL("/swagger/doc.json"),
+ httpSwagger.DeepLinking(true),
+ httpSwagger.DocExpansion("none"),
+ httpSwagger.DomID("#swagger-ui"),
+ ))
+
rtr.PathPrefix("/api/v1").Handler(
http.StripPrefix("/api/v1", a.HandleAPIv1()))
@@ -16,9 +27,9 @@ func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
rtr.Handle("/setLib", UnauthorizedIfNotLocal(http.HandlerFunc(a.HandleSetLib)))
rtr.Handle("/delete", UnauthorizedIfNotLocal(http.HandlerFunc(a.HandleDelete)))
rtr.Handle("/install", UnauthorizedIfNotLocal(http.HandlerFunc(a.HandleInstall)))
- rtr.Handle("/status", UnauthorizedIfNotLocal(http.HandlerFunc(a.HandleStats)))
+ rtr.Handle("/status", UnauthorizedIfNotLocal(a.HandleStats()))
- rtr.HandleFunc("/steam-export-web.exe", ServeSelf)
+ rtr.Handle("/steam-export-web.exe", HandleSelfServe())
rtr.HandleFunc("/download/{game}", a.HandleDownload)
rtr.PathPrefix("/static").Handler(
http.FileServer(http.FS(a.staticFS)))
@@ -32,11 +43,12 @@ func (a *App) HandleAPIv1() http.Handler {
rtr := mux.NewRouter()
rtr.Handle("/quit", UnauthorizedIfNotLocal(http.HandlerFunc(HandleQuit)))
+ rtr.Handle("/status", a.HandleStats())
rtr.Handle("/share-link", http.HandlerFunc(a.HandleShareLink))
rtr.Handle("/version", http.HandlerFunc(a.HandleVersion))
rtr.Path("/lib/games").Methods("GET").HandlerFunc(a.HandleGameList)
rtr.Path("/lib/game/{game}").Methods("GET").HandlerFunc(a.HandleDownload)
- rtr.Path("/lib/game/{game}").Methods("Delete").Handler(
+ rtr.Path("/lib/game/{game}").Methods("DELETE").Handler(
UnauthorizedIfNotLocal(http.HandlerFunc(a.HandleDeleteV1)))
rtr.Path("/lib/refresh").Methods("GET", "POST").Handler(
UnauthorizedIfNotLocal(http.HandlerFunc(a.HandleRefresh)))