version = "0.1";
system = "x86_64-linux";
pkgs = import nixpkgs {inherit system;};
+
+ go-watch = pkgs.writeScriptBin "go-watch" ''
+ #!${pkgs.stdenv.shell}
+ find . -name "*.go" | ${pkgs.entr}/bin/entr -r ${pkgs.nix}/bin/nix run
+ '';
in
{
packages.${system}.default = pkgs.buildGoModule {
gopls
gotools
go-tools
+
+ git
+ entr
+ curl
+ go-watch
];
+ shellHook = ''
+ echo "Welcome to monopoly-web backend."
+ echo "Run 'go-watch' to hot reload the go server"
+ '';
};
};
};
);
func main() {
- fmt.Println("ur mom")
+ fmt.Println("monopoly-web")
- helloHandler:= func(w http.ResponseWriter, req *http.Request) {
- io.WriteString(w, "Hello ur mom!\n")
+ healthHandler:= func(w http.ResponseWriter, req *http.Request) {
+ io.WriteString(w, "Status: healthy\n")
}
- http.HandleFunc("/hello", helloHandler)
+ http.HandleFunc("/health", healthHandler)
log.Fatal(http.ListenAndServe(":8080",nil))
}