We've got some json REST API implemented with *go-swagger*. Now we would
like to add some simple web UI (several static html, js and css files)
hosted by the same http server. The implementation is fairly simple.
Swagger YAML:
/ui/html/{path}:
get:
...
produces:
- text/html
/ui/js/{path}:
get:
...
produces:
- application/javascript
/ui/css/{path}:
get:
...
produces:
- text/css
and GO handler:
api.GetHTML = operations.GetHTMLFunc(
func(params operations.GetHTMLParams) middleware.Responder {
bytes, _ := ioutil.ReadFile(params.Path)
return operations.NewGetHTMLOK().WithPayload(string(bytes))
})
... the same for JS and CSS ...
Unfortunately this looks ugly as hell. Each content type needs its own path
on the server. Is there a better way? Would it be possible to modify reply
content type by the header?
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.