fix code formatting
All checks were successful
Build and publish the docker image / build (push) Successful in 1m2s
All checks were successful
Build and publish the docker image / build (push) Successful in 1m2s
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
@ -7,41 +7,41 @@ import (
|
||||
)
|
||||
|
||||
type translate_form struct {
|
||||
Dictionary string
|
||||
Term string
|
||||
Dictionary string
|
||||
Term string
|
||||
}
|
||||
|
||||
func POST_translate(c *fiber.Ctx) error {
|
||||
var (
|
||||
extractor *extract.Extractor
|
||||
trans *extract.Translation
|
||||
form translate_form
|
||||
err error
|
||||
)
|
||||
var (
|
||||
extractor *extract.Extractor
|
||||
trans *extract.Translation
|
||||
form translate_form
|
||||
err error
|
||||
)
|
||||
|
||||
extractor = c.Locals("extractor").(*extract.Extractor)
|
||||
extractor = c.Locals("extractor").(*extract.Extractor)
|
||||
|
||||
if err = c.BodyParser(&form); err != nil {
|
||||
return util.RenderError(c, 400)
|
||||
}
|
||||
if err = c.BodyParser(&form); err != nil {
|
||||
return util.RenderError(c, 400)
|
||||
}
|
||||
|
||||
if form.Dictionary == "" || form.Term == "" {
|
||||
return util.RenderError(c, 400)
|
||||
}
|
||||
if form.Dictionary == "" || form.Term == "" {
|
||||
return util.RenderError(c, 400)
|
||||
}
|
||||
|
||||
if trans, err = extractor.Translate(form.Dictionary, form.Term); err != nil {
|
||||
return util.RenderError(c, 500, err)
|
||||
}
|
||||
if trans, err = extractor.Translate(form.Dictionary, form.Term); err != nil {
|
||||
return util.RenderError(c, 500, err)
|
||||
}
|
||||
|
||||
if trans == nil {
|
||||
return util.RenderError(c, 400)
|
||||
}
|
||||
if trans == nil {
|
||||
return util.RenderError(c, 400)
|
||||
}
|
||||
|
||||
return util.Render(c, "translate", fiber.Map{
|
||||
"term": form.Term,
|
||||
"dictionary": form.Dictionary,
|
||||
"fields": trans.Fields,
|
||||
"entries": trans.Entries,
|
||||
"suggestions": trans.Suggestions,
|
||||
})
|
||||
return util.Render(c, "translate", fiber.Map{
|
||||
"term": form.Term,
|
||||
"dictionary": form.Dictionary,
|
||||
"fields": trans.Fields,
|
||||
"entries": trans.Entries,
|
||||
"suggestions": trans.Suggestions,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user