mirror of
https://codeberg.org/andyscott/OpenWeather-gRPC-API.git
synced 2024-12-21 12:13:09 -05:00
Added some basic documentation
This commit is contained in:
parent
ba7e27dfea
commit
87a9143248
3 changed files with 8 additions and 0 deletions
|
@ -10,6 +10,8 @@ import (
|
|||
pb "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"
|
||||
)
|
||||
|
||||
// Receives a gRPC request for the current forecast
|
||||
// Returns a SendCurrent message containing the forecast in JSON
|
||||
func (s *Server) Current(ctx context.Context, in *pb.RequestCurrent) (*pb.SendCurrent, error) {
|
||||
log.Println("'Current' function called...")
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ import (
|
|||
pb "codeberg.org/andcscott/OpenWeatherMap-gRPC-API/proto"
|
||||
)
|
||||
|
||||
// Receives a gRPC request for an extended forecast
|
||||
// Returns a SendExtended message with the forecast in JSON
|
||||
func (s *Server) Extended(ctx context.Context, in *pb.RequestExtended) (*pb.SendExtended, error) {
|
||||
log.Println("'Extended' function called...")
|
||||
|
||||
|
|
|
@ -18,13 +18,16 @@ type Server struct {
|
|||
|
||||
func main() {
|
||||
|
||||
// Load .env file
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
// Read PORT from .env
|
||||
port, _ := strconv.Atoi(os.Getenv("PORT"))
|
||||
|
||||
// Start server
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
|
||||
if err != nil {
|
||||
log.Fatalf("Error starting server: %v\n", err)
|
||||
|
@ -32,6 +35,7 @@ func main() {
|
|||
log.Printf("Listening on port %d...\n", port)
|
||||
}
|
||||
|
||||
// Initialize gRPC server
|
||||
s := grpc.NewServer()
|
||||
pb.RegisterWeatherServiceServer(s, &Server{})
|
||||
if err = s.Serve(lis); err != nil {
|
||||
|
|
Loading…
Reference in a new issue