Updated examples to match

This commit is contained in:
Sasha Koshka 2023-05-29 21:22:46 -04:00
parent d716aa9455
commit 1e1ae572f2
4 changed files with 10 additions and 24 deletions

View File

@ -1,7 +1,6 @@
package main package main
import "fmt" import "fmt"
import "log"
import "net/http" import "net/http"
import "hnakra/service" import "hnakra/service"
@ -11,13 +10,9 @@ func main () {
http.HandleFunc("/gifs/", gifs) http.HandleFunc("/gifs/", gifs)
http.Handle("/gifs/static/", http.StripPrefix("/gifs/static", static)) http.Handle("/gifs/static/", http.StripPrefix("/gifs/static", static))
err := service.NewHTTP ( service.NewService (
"Gifs", "Serves a lot of big gifs on one page.", "Gifs", "Serves a lot of big gifs on one page.",
"@", "/gifs/").Run() service.NewHTTP("@", "/gifs/", nil)).Run()
if err != nil {
log.Println("XXX", err)
}
} }
func gifs (res http.ResponseWriter, req *http.Request) { func gifs (res http.ResponseWriter, req *http.Request) {

View File

@ -1,16 +1,13 @@
package main package main
import "log"
import "net/http" import "net/http"
import "hnakra/service" import "hnakra/service"
func main () { func main () {
http.HandleFunc("/hello/", hellorld) http.HandleFunc("/hello/", hellorld)
err := service.NewHTTP("Hellorld", "A test service.", "@", "/hello/").Run() service.NewService (
"Hellorld", "A test service.",
if err != nil { service.NewHTTP("@", "/hello/", nil)).Run()
log.Println("XXX", err)
}
} }
func hellorld (res http.ResponseWriter, req *http.Request) { func hellorld (res http.ResponseWriter, req *http.Request) {

View File

@ -1,6 +1,5 @@
package main package main
import "log"
import "net/http" import "net/http"
import "hnakra/service" import "hnakra/service"
@ -13,10 +12,7 @@ func main () {
// do with how *something* is caching the file. // do with how *something* is caching the file.
http.ServeFile(res, req, "fractal.png") http.ServeFile(res, req, "fractal.png")
}) })
service.NewService (
err := service.NewHTTP ( "Image", "Displays an image of a fractal.",
"Image", service.NewHTTP("@", "/fractal.png", nil)).Run()
"Displays an image of a fractal.",
"@", "/fractal.png").Run()
if err != nil { log.Println("XXX", err) }
} }

View File

@ -6,12 +6,10 @@ import "hnakra/service"
func main () { func main () {
http.HandleFunc("/kamikaze/", hellorld) http.HandleFunc("/kamikaze/", hellorld)
service.NewService (
err := service.NewHTTP (
"Kamikaze", "Kamikaze",
"A service that abrupltly closes upon any request, for testing.", "A service that abrupltly closes upon any request, for testing.",
"@", "/kamikaze/").Run() service.NewHTTP("@", "/kamikaze/", nil)).Run()
if err != nil { log.Println("XXX", err) }
} }
func hellorld (res http.ResponseWriter, req *http.Request) { func hellorld (res http.ResponseWriter, req *http.Request) {