Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APISPAServer ¶
APISPAServer is a representation of a basic server that serves a single page application (SPA) and an application programming interface (API).
The server is created by calling e.g.:
s := NewAPISPAServer("8080")
After which, API routes can be registered on the server's router:
r := &server.Router r.HandleFunc("/api/v1/status", getStatus).Methods("GET")
By default, the SPA is served from:
`./public/index.html`
The SPA directory can be changed by calling:
server.SetSPA("public/service-xy")
This will then serve:
`./public/service-xy/index.html`
Finally, the server can be started:
log.Fatal(server.ListenAndServe())
func NewAPISPAServer ¶
func NewAPISPAServer(port string) *APISPAServer
NewAPISPAServer returns a new server instance.
By default it will serve:
`./public/index.html`
for the single page application.
func (*APISPAServer) ListenAndServe ¶
func (server *APISPAServer) ListenAndServe() error
Start the server and listen to requests on the specified port.
func (*APISPAServer) SetSPA ¶
func (server *APISPAServer) SetSPA(path string)
Set the path to the single page application.
The path passed should point to the directory where `index.html` lies, though without tailing slash:
srv.SetSPA("public/admin")