github.com/cs3org/reva/v2@v2.27.7/pkg/micro/ocdav/cmd/main.go (about)

     1  // Copyright 2018-2021 CERN
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  // In applying this license, CERN does not waive the privileges and immunities
    16  // granted to it by virtue of its status as an Intergovernmental Organization
    17  // or submit itself to any jurisdiction.
    18  
    19  package main
    20  
    21  import (
    22  	"os"
    23  
    24  	"github.com/cs3org/reva/v2/pkg/micro/ocdav"
    25  	"github.com/rs/zerolog"
    26  )
    27  
    28  // main starts a go micro service that uses the ocdev handler
    29  // It is an example how to use pkg/micro/ocdav Service and leaves out any flag parsing.
    30  func main() {
    31  	zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
    32  	logger := zerolog.New(os.Stdout).With().Timestamp().Logger()
    33  
    34  	s, err := ocdav.Service(
    35  		ocdav.Logger(logger),
    36  		ocdav.GatewaySvc("127.0.0.1:9142"),
    37  		ocdav.FilesNamespace("/users/{{.Id.OpaqueId}}"),
    38  		ocdav.WebdavNamespace("/users/{{.Id.OpaqueId}}"),
    39  		ocdav.OCMNamespace("/public"),
    40  		ocdav.SharesNamespace("/Shares"),
    41  	)
    42  	if err != nil {
    43  		logger.Fatal().Err(err).Msg("failed starting ocdav service")
    44  		return
    45  	}
    46  	if err := s.Run(); err != nil {
    47  		logger.Fatal().Err(err).Msg("ocdav service exited with error")
    48  	}
    49  }