This commit is contained in:
Arya 2023-09-11 09:15:41 +05:30
parent 2b69cc687c
commit 583288bf01
Signed by: arya
GPG Key ID: 842D12BDA50DF120
4 changed files with 37 additions and 37 deletions

View File

@ -29,9 +29,9 @@ const docTemplate = `{
], ],
"responses": { "responses": {
"200": { "200": {
"description": "success", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/utils.List" "$ref": "#/definitions/libmozhi.List"
} }
} }
} }
@ -51,9 +51,9 @@ const docTemplate = `{
], ],
"responses": { "responses": {
"200": { "200": {
"description": "success", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/utils.List" "$ref": "#/definitions/libmozhi.List"
} }
} }
} }
@ -95,9 +95,9 @@ const docTemplate = `{
], ],
"responses": { "responses": {
"200": { "200": {
"description": "success", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/utils.LangOut" "$ref": "#/definitions/libmozhi.LangOut"
} }
} }
} }
@ -134,7 +134,7 @@ const docTemplate = `{
} }
}, },
"definitions": { "definitions": {
"utils.LangOut": { "libmozhi.LangOut": {
"type": "object", "type": "object",
"properties": { "properties": {
"detected": { "detected": {
@ -154,7 +154,7 @@ const docTemplate = `{
} }
} }
}, },
"utils.List": { "libmozhi.List": {
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "id": {

View File

@ -18,9 +18,9 @@
], ],
"responses": { "responses": {
"200": { "200": {
"description": "success", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/utils.List" "$ref": "#/definitions/libmozhi.List"
} }
} }
} }
@ -40,9 +40,9 @@
], ],
"responses": { "responses": {
"200": { "200": {
"description": "success", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/utils.List" "$ref": "#/definitions/libmozhi.List"
} }
} }
} }
@ -84,9 +84,9 @@
], ],
"responses": { "responses": {
"200": { "200": {
"description": "success", "description": "OK",
"schema": { "schema": {
"$ref": "#/definitions/utils.LangOut" "$ref": "#/definitions/libmozhi.LangOut"
} }
} }
} }
@ -123,7 +123,7 @@
} }
}, },
"definitions": { "definitions": {
"utils.LangOut": { "libmozhi.LangOut": {
"type": "object", "type": "object",
"properties": { "properties": {
"detected": { "detected": {
@ -143,7 +143,7 @@
} }
} }
}, },
"utils.List": { "libmozhi.List": {
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "id": {

View File

@ -1,5 +1,5 @@
definitions: definitions:
utils.LangOut: libmozhi.LangOut:
properties: properties:
detected: detected:
type: string type: string
@ -12,7 +12,7 @@ definitions:
translated-text: translated-text:
type: string type: string
type: object type: object
utils.List: libmozhi.List:
properties: properties:
id: id:
type: string type: string
@ -32,9 +32,9 @@ paths:
type: string type: string
responses: responses:
"200": "200":
description: success description: OK
schema: schema:
$ref: '#/definitions/utils.List' $ref: '#/definitions/libmozhi.List'
summary: Show list of available source languages for engine summary: Show list of available source languages for engine
/api/target_languages: /api/target_languages:
get: get:
@ -46,9 +46,9 @@ paths:
type: string type: string
responses: responses:
"200": "200":
description: success description: OK
schema: schema:
$ref: '#/definitions/utils.List' $ref: '#/definitions/libmozhi.List'
summary: Show list of available target languages for engine summary: Show list of available target languages for engine
/api/translate: /api/translate:
get: get:
@ -76,9 +76,9 @@ paths:
type: string type: string
responses: responses:
"200": "200":
description: success description: OK
schema: schema:
$ref: '#/definitions/utils.LangOut' $ref: '#/definitions/libmozhi.LangOut'
summary: Translate text summary: Translate text
/api/tts: /api/tts:
get: get:

View File

@ -83,6 +83,19 @@ func Serve(port string) {
return c.Next() 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("/", pages.HandleIndex)
app.Get("/about", pages.HandleAbout) app.Get("/about", pages.HandleAbout)
app.Get("/switchlanguages", func(c *fiber.Ctx) error { app.Get("/switchlanguages", func(c *fiber.Ctx) error {
@ -97,19 +110,6 @@ func Serve(port string) {
Root: http.FS(public.GetFiles()), 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") val, ok := os.LookupEnv("MOZHI_PORT")
if !ok { if !ok {
val = "3000" val = "3000"