mirror of
https://github.com/go-kratos/kratos.git
synced 2026-05-22 10:15:24 +02:00
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>This is an example of a simple HTML page with one paragraph.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,33 @@
|
||||
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.Println(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user