feat: add swagger support
This commit is contained in:
parent
f5e437777a
commit
49c3844406
34
main.go
34
main.go
|
@ -4,8 +4,10 @@ import (
|
||||||
"embed"
|
"embed"
|
||||||
"git.lumeweb.com/LumeWeb/portal/config"
|
"git.lumeweb.com/LumeWeb/portal/config"
|
||||||
"git.lumeweb.com/LumeWeb/portal/db"
|
"git.lumeweb.com/LumeWeb/portal/db"
|
||||||
"git.lumeweb.com/LumeWeb/portal/renterd"
|
_ "git.lumeweb.com/LumeWeb/portal/docs"
|
||||||
"git.lumeweb.com/LumeWeb/portal/service"
|
"git.lumeweb.com/LumeWeb/portal/service"
|
||||||
|
"github.com/iris-contrib/swagger"
|
||||||
|
"github.com/iris-contrib/swagger/swaggerFiles"
|
||||||
"github.com/kataras/iris/v12"
|
"github.com/kataras/iris/v12"
|
||||||
"github.com/kataras/iris/v12/mvc"
|
"github.com/kataras/iris/v12/mvc"
|
||||||
"log"
|
"log"
|
||||||
|
@ -15,6 +17,19 @@ import (
|
||||||
//go:embed app/*
|
//go:embed app/*
|
||||||
var embedFrontend embed.FS
|
var embedFrontend embed.FS
|
||||||
|
|
||||||
|
// @title Lume Web Portal
|
||||||
|
// @version 1.0
|
||||||
|
// @description A decentralized data storage portal for the open web
|
||||||
|
|
||||||
|
// @contact.name Lume Web Project
|
||||||
|
// @contact.url https://lumeweb.com
|
||||||
|
// @contact.email contact@lumeweb.com
|
||||||
|
|
||||||
|
// @license.name MIT
|
||||||
|
// @license.url https://opensource.org/license/mit/
|
||||||
|
|
||||||
|
// @externalDocs.description OpenAPI
|
||||||
|
// @externalDocs.url https://swagger.io/resources/open-api/
|
||||||
func main() {
|
func main() {
|
||||||
// Initialize the configuration settings
|
// Initialize the configuration settings
|
||||||
config.Init()
|
config.Init()
|
||||||
|
@ -40,8 +55,23 @@ func main() {
|
||||||
app.Handle(new(service.AuthService))
|
app.Handle(new(service.AuthService))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
config := swagger.Config{
|
||||||
|
// The url pointing to API definition.
|
||||||
|
URL: "http://localhost:8080/swagger/doc.json",
|
||||||
|
DeepLinking: true,
|
||||||
|
DocExpansion: "list",
|
||||||
|
DomID: "#swagger-ui",
|
||||||
|
// The UI prefix URL (see route).
|
||||||
|
Prefix: "/swagger",
|
||||||
|
}
|
||||||
|
swaggerUI := swagger.Handler(swaggerFiles.Handler, config)
|
||||||
|
|
||||||
|
app.Get("/swagger", swaggerUI)
|
||||||
|
// And the wildcard one for index.html, *.js, *.css and e.t.c.
|
||||||
|
app.Get("/swagger/{any:path}", swaggerUI)
|
||||||
|
|
||||||
// Start the renterd process in a goroutine
|
// Start the renterd process in a goroutine
|
||||||
go renterd.Main()
|
//go renterd.Main()
|
||||||
|
|
||||||
// Start the Iris app and listen for incoming requests on port 80
|
// Start the Iris app and listen for incoming requests on port 80
|
||||||
log.Fatal(app.Listen(":80"))
|
log.Fatal(app.Listen(":80"))
|
||||||
|
|
Loading…
Reference in New Issue