Hard coded units for now, minor formatting updates

This commit is contained in:
Andrew Scott 2022-07-26 03:52:33 -04:00
parent 6b89ae295b
commit 1cef0eba5a
Signed by: a
GPG key ID: 3EB62D0BBB8DB381
3 changed files with 6 additions and 7 deletions

View file

@ -16,7 +16,7 @@ func getCurrent(in *pb.RequestCurrent) string {
url := "https://pro.openweathermap.org/data/2.5/weather?q="
token := "&appid=" + os.Getenv("API_KEY")
url = url + city + token
url = url + city + "&units=imperial" + token
res, err := http.Get(url)
if err != nil {
@ -28,12 +28,10 @@ func getCurrent(in *pb.RequestCurrent) string {
if err != nil {
log.Printf("Error reading weather response: %v", err)
}
return string(body)
}
func (s *server) Current(ctx context.Context, in *pb.RequestCurrent) (*pb.SendCurrent, error) {
func (s *Server) Current(ctx context.Context, in *pb.RequestCurrent) (*pb.SendCurrent, error) {
log.Println("'Current' function called...")
return &pb.SendCurrent{

View file

@ -12,7 +12,7 @@ import (
"google.golang.org/grpc"
)
type server struct {
type Server struct {
pb.WeatherServiceServer
}
@ -33,7 +33,7 @@ func main() {
}
s := grpc.NewServer()
pb.RegisterWeatherServiceServer(s, &server{})
pb.RegisterWeatherServiceServer(s, &Server{})
if err = s.Serve(lis); err != nil {
log.Fatalf("gRPC Server error: %v\n", err)
}

View file

@ -18,5 +18,6 @@ func main() {
c := pb.NewWeatherServiceClient(conn)
doCurrent(c)
//doCurrent(c)
doExtended(c)
}