This commit is contained in:
Arya Kiran 2023-09-11 09:15:41 +05:30
parent 2b69cc687c
commit 583288bf01
No known key found for this signature in database
GPG key ID: 842D12BDA50DF120
4 changed files with 37 additions and 37 deletions

View file

@ -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": {

View file

@ -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": {

View file

@ -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:

View file

@ -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"