github.com/cs3org/reva/v2@v2.27.7/internal/http/services/owncloud/ocdav/status.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 ocdav
    20  
    21  import (
    22  	"encoding/json"
    23  	"net/http"
    24  
    25  	"github.com/cs3org/reva/v2/pkg/appctx"
    26  	"github.com/cs3org/reva/v2/pkg/owncloud/ocs"
    27  )
    28  
    29  func (s *svc) doStatus(w http.ResponseWriter, r *http.Request) {
    30  	log := appctx.GetLogger(r.Context())
    31  	status := &ocs.Status{
    32  		Installed:      true,
    33  		Maintenance:    false,
    34  		NeedsDBUpgrade: false,
    35  		Version:        s.c.Version,
    36  		VersionString:  s.c.VersionString,
    37  		Edition:        s.c.Edition,
    38  		ProductName:    s.c.ProductName,
    39  		ProductVersion: s.c.ProductVersion,
    40  		Product:        s.c.Product,
    41  	}
    42  
    43  	statusJSON, err := json.MarshalIndent(status, "", "    ")
    44  	if err != nil {
    45  		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
    46  		return
    47  	}
    48  
    49  	w.Header().Add("Content-Type", "application/json")
    50  	w.WriteHeader(http.StatusOK)
    51  	if _, err := w.Write(statusJSON); err != nil {
    52  		log.Err(err).Msg("error writing response")
    53  	}
    54  }