Initial commit
This commit is contained in:
26
examples/hellorld/main.go
Normal file
26
examples/hellorld/main.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import "log"
|
||||
import "net/http"
|
||||
import "crypto/tls"
|
||||
import "hnakra/service"
|
||||
|
||||
func main () {
|
||||
http.HandleFunc("/hello/", hellorld)
|
||||
err := (&service.HTTP { Mount: service.Mount {
|
||||
Path: "/hello/",
|
||||
Name: "Hellorld",
|
||||
Description: "A test service.",
|
||||
TLSConfig: &tls.Config { InsecureSkipVerify: true },
|
||||
}}).Run()
|
||||
|
||||
if err != nil {
|
||||
log.Println("XXX", err)
|
||||
}
|
||||
}
|
||||
|
||||
func hellorld (res http.ResponseWriter, req *http.Request) {
|
||||
res.Header().Add("content-type", "text/plain")
|
||||
res.WriteHeader(200)
|
||||
res.Write([]byte("Hellorld!\n"))
|
||||
}
|
||||
Reference in New Issue
Block a user