mirror of
https://codeberg.org/aryak/mozhi
synced 2024-11-08 19:12:25 +05:30
put api before the static handling (https://github.com/gofiber/swagger/issues/33)
This commit is contained in:
parent
2b69cc687c
commit
583288bf01
16
docs/docs.go
16
docs/docs.go
@ -29,9 +29,9 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.List"
|
||||
"$ref": "#/definitions/libmozhi.List"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,9 +51,9 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.List"
|
||||
"$ref": "#/definitions/libmozhi.List"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,9 +95,9 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.LangOut"
|
||||
"$ref": "#/definitions/libmozhi.LangOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"utils.LangOut": {
|
||||
"libmozhi.LangOut": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"detected": {
|
||||
@ -154,7 +154,7 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"utils.List": {
|
||||
"libmozhi.List": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
|
@ -18,9 +18,9 @@
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.List"
|
||||
"$ref": "#/definitions/libmozhi.List"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,9 +40,9 @@
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.List"
|
||||
"$ref": "#/definitions/libmozhi.List"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,9 +84,9 @@
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "success",
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.LangOut"
|
||||
"$ref": "#/definitions/libmozhi.LangOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"utils.LangOut": {
|
||||
"libmozhi.LangOut": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"detected": {
|
||||
@ -143,7 +143,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"utils.List": {
|
||||
"libmozhi.List": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
|
@ -1,5 +1,5 @@
|
||||
definitions:
|
||||
utils.LangOut:
|
||||
libmozhi.LangOut:
|
||||
properties:
|
||||
detected:
|
||||
type: string
|
||||
@ -12,7 +12,7 @@ definitions:
|
||||
translated-text:
|
||||
type: string
|
||||
type: object
|
||||
utils.List:
|
||||
libmozhi.List:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
@ -32,9 +32,9 @@ paths:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: success
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/utils.List'
|
||||
$ref: '#/definitions/libmozhi.List'
|
||||
summary: Show list of available source languages for engine
|
||||
/api/target_languages:
|
||||
get:
|
||||
@ -46,9 +46,9 @@ paths:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: success
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/utils.List'
|
||||
$ref: '#/definitions/libmozhi.List'
|
||||
summary: Show list of available target languages for engine
|
||||
/api/translate:
|
||||
get:
|
||||
@ -76,9 +76,9 @@ paths:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: success
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/utils.LangOut'
|
||||
$ref: '#/definitions/libmozhi.LangOut'
|
||||
summary: Translate text
|
||||
/api/tts:
|
||||
get:
|
||||
|
@ -83,6 +83,19 @@ func Serve(port string) {
|
||||
return c.Next()
|
||||
})
|
||||
|
||||
api := app.Group("/api")
|
||||
api.Get("/translate", pages.HandleTranslate)
|
||||
api.Get("/source_languages", pages.HandleSourceLanguages)
|
||||
api.Get("/target_languages", pages.HandleTargetLanguages)
|
||||
api.Get("/tts", pages.HandleTTS)
|
||||
api.Get("/version", func(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{
|
||||
"fiberversion": fiber.Version,
|
||||
"goversion": runtime.Version(),
|
||||
})
|
||||
})
|
||||
api.Get("/swagger/*", swagger.HandlerDefault) // default
|
||||
|
||||
app.Get("/", pages.HandleIndex)
|
||||
app.Get("/about", pages.HandleAbout)
|
||||
app.Get("/switchlanguages", func(c *fiber.Ctx) error {
|
||||
@ -97,19 +110,6 @@ func Serve(port string) {
|
||||
Root: http.FS(public.GetFiles()),
|
||||
}))
|
||||
|
||||
api := app.Group("/api")
|
||||
api.Get("/translate", pages.HandleTranslate)
|
||||
api.Get("/source_languages", pages.HandleSourceLanguages)
|
||||
api.Get("/target_languages", pages.HandleTargetLanguages)
|
||||
api.Get("/tts", pages.HandleTTS)
|
||||
api.Get("/version", func(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{
|
||||
"fiberversion": fiber.Version,
|
||||
"goversion": runtime.Version(),
|
||||
})
|
||||
})
|
||||
api.Get("/swagger/*", swagger.HandlerDefault) // default
|
||||
|
||||
val, ok := os.LookupEnv("MOZHI_PORT")
|
||||
if !ok {
|
||||
val = "3000"
|
||||
|
Loading…
Reference in New Issue
Block a user