Skip to content

Commit

Permalink
feat(cmd/example_server): Add /dela.jpg image endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Feb 15, 2024
1 parent cd56030 commit c04d991
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/example_server/example_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"time"

"github.com/ondrejsika/go-dela"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sikalabs/slu/cmd/root"
Expand Down Expand Up @@ -75,6 +76,13 @@ var Cmd = &cobra.Command{
fmt.Fprintf(w, "[slu "+version.Version+"] Example HTTP Server (after 15m)! %s %s \n", hostname, portStr)
})

http.HandleFunc("/dela.jpg", func(w http.ResponseWriter, r *http.Request) {
requestsTotal.Inc()
w.Header().Set("Content-Type", "image/jpeg")
w.WriteHeader(http.StatusOK)
w.Write(dela.DELA1_JPG)
})

http.Handle("/metrics", promhttp.Handler())

fmt.Println("[slu " + version.Version + "] Server started on 0.0.0.0:" + portStr + ", see http://127.0.0.1:" + portStr)
Expand Down

0 comments on commit c04d991

Please sign in to comment.