mirror of
https://codeberg.org/andyscott/OpenWeather-gRPC-API.git
synced 2024-12-29 13:23:11 -05:00
Hard coded units for now, minor formatting updates
This commit is contained in:
parent
6b89ae295b
commit
1cef0eba5a
3 changed files with 6 additions and 7 deletions
|
@ -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{
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -18,5 +18,6 @@ func main() {
|
|||
|
||||
c := pb.NewWeatherServiceClient(conn)
|
||||
|
||||
doCurrent(c)
|
||||
//doCurrent(c)
|
||||
doExtended(c)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue