mirror of
https://github.com/slsa-framework/slsa-verifier.git
synced 2026-05-11 11:06:38 +00:00
* update * update * update * tests * update * update * update * update * update * update * update * update * update * update * comments * update * update * update * update * update
39 lines
783 B
Go
39 lines
783 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"github.com/slsa-framework/slsa-verifier/experimental/rest"
|
|
)
|
|
|
|
func main() {
|
|
r := mux.NewRouter().StrictSlash(true)
|
|
|
|
r.HandleFunc("/", HomeHandler).Methods(http.MethodGet)
|
|
r.HandleFunc("/v1/verify", rest.VerifyHandlerV1).Methods(http.MethodPost)
|
|
http.Handle("/", r)
|
|
|
|
address := ":8000"
|
|
fmt.Printf("Starting HTTP server on %v ...\n", address)
|
|
srv := &http.Server{
|
|
Handler: r,
|
|
Addr: address,
|
|
// Good practice: enforce timeouts for servers you create!
|
|
WriteTimeout: 15 * time.Second,
|
|
ReadTimeout: 15 * time.Second,
|
|
}
|
|
|
|
if err := srv.ListenAndServe(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func HomeHandler(w http.ResponseWriter, r *http.Request) {
|
|
w.WriteHeader(http.StatusOK)
|
|
}
|