mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-12 22:07:47 +02:00
Add web and update deps
This commit is contained in:
29
web/examples/helloworld/helloworld.go
Normal file
29
web/examples/helloworld/helloworld.go
Normal file
@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/micro/go-micro/web"
|
||||
)
|
||||
|
||||
func helloWorldHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `<html><body><h1>Hello World</h1></body></html>`)
|
||||
}
|
||||
|
||||
func main() {
|
||||
service := web.NewService(
|
||||
web.Name("helloworld"),
|
||||
)
|
||||
|
||||
service.HandleFunc("/", helloWorldHandler)
|
||||
|
||||
if err := service.Init(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := service.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user