ddo / go-vue-handler

Host Vue app with Router history mode in Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-vue-handler

Vue Router history mode with Golang

installation

go get -u github.com/ddo/go-vue-handler

usage

  • build vue app to get index.html and dist folder
  • serve it as a static folder with go server
  • all the static files must has extension

example

/
    public/
        dist
        index.html
    server.go
package main

import (
	"net/http"

	"github.com/ddo/go-vue-handler"
)

const (
	port = "8080"
	publicDir = "./public"
)

func main() {
	server := &http.Server{
		Addr:    ":" + port,
		Handler: vue.Handler(publicDir),
	}
	err := server.ListenAndServe()
	panic(err)
}

About

Host Vue app with Router history mode in Golang

License:MIT License


Languages

Language:Go 63.6%Language:HTML 36.4%