mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-22 15:49:34 -05:00
* chore: update Go version to 1.22 for consistency across workflows, jobs, and modules. * build: Update GitHub Actions setup-go and golangci-lint versions. * refactor: Replace ioutil.ReadFile and ioutil.ReadAll with os.ReadFile and io.ReadAll. * go fmt * 🔄 Update actions/checkout and actions/setup-go to v4 and v5, respectively. * ✨ Refactor: Add b64 function to convert file to base64 in testacc_setup.sh. * ✨ Update Go version requirement in CONTRIBUTING.md. * ✨ Fix typo and improve error message format. * ✨ enhance: Improve error message in TestAccDockerContainer_uploadAsBase64. * ✨ Fix: Update file permissions for test2.txt in docker container tests.
45 lines
967 B
Go
45 lines
967 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
const listenAddr = ":8085" // changed here on purpose
|
|
|
|
type config struct {
|
|
Prefix string `json:"prefix"`
|
|
}
|
|
|
|
func main() {
|
|
configsContent, err := os.ReadFile("configs.json")
|
|
if err != nil {
|
|
log.Fatalf("cannot open 'configs.json': %s", err)
|
|
}
|
|
|
|
var configs config
|
|
err = json.Unmarshal(configsContent, &configs)
|
|
if err != nil {
|
|
log.Fatalf("cannot unmarshal 'configs.json': %s", err)
|
|
}
|
|
|
|
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
|
|
w.WriteHeader(http.StatusOK)
|
|
})
|
|
|
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
w.WriteHeader(http.StatusOK)
|
|
_, err = w.Write([]byte(fmt.Sprintf("%s - Hello World!", configs.Prefix)))
|
|
if err != nil {
|
|
log.Fatalln("failed to write for path '/'")
|
|
}
|
|
})
|
|
|
|
err = http.ListenAndServe(listenAddr, nil)
|
|
if err != nil {
|
|
log.Fatalf("failed to listen and server on port '%s'", listenAddr)
|
|
}
|
|
}
|