1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-07 23:02:12 +02:00
kratos/examples/http/static/main.go
Tony Chen 00088f644a
examples: clean examples (#1036)
* clean examples

* update yaml to v3
2021-06-12 20:20:18 +08:00

34 lines
586 B
Go

package main
import (
"embed"
"log"
"net/http"
"github.com/go-kratos/kratos/v2"
transhttp "github.com/go-kratos/kratos/v2/transport/http"
"github.com/gorilla/mux"
)
//go:embed assets/*
var f embed.FS
func main() {
router := mux.NewRouter()
// example: /assets/index.html
router.PathPrefix("/assets").Handler(http.FileServer(http.FS(f)))
httpSrv := transhttp.NewServer(transhttp.Address(":8000"))
httpSrv.HandlePrefix("/", router)
app := kratos.New(
kratos.Name("static"),
kratos.Server(
httpSrv,
),
)
if err := app.Run(); err != nil {
log.Fatal(err)
}
}