Skip to content

Commit

Permalink
a placeholder for /ocs/v2.php/apps/notifications/api/v1/notifications (
Browse files Browse the repository at this point in the history
…#417)

* a placehodler for /ocs/v2.php/apps/notifications/api/v1/notifications?format=json to stop javascript console getting 404

* added struct comment

* playing with lint
  • Loading branch information
madsi1m authored and labkode committed Dec 10, 2019
1 parent ee58c96 commit c190ea4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/http/services/owncloud/ocs/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import (

// AppsHandler holds references to individual app handlers
type AppsHandler struct {
SharesHandler *SharesHandler
SharesHandler *SharesHandler
NotificationsHandler *NotificationsHandler
}

func (h *AppsHandler) init(c *Config) error {
h.SharesHandler = new(SharesHandler)
h.NotificationsHandler = new(NotificationsHandler)
return h.SharesHandler.init(c)
}

Expand All @@ -49,6 +51,16 @@ func (h *AppsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
WriteOCSError(w, r, MetaNotFound.StatusCode, "Not found", nil)
case "notifications":
head, r.URL.Path = rhttp.ShiftPath(r.URL.Path)
if head == "api" {
head, r.URL.Path = rhttp.ShiftPath(r.URL.Path)
if head == "v1" {
h.NotificationsHandler.ServeHTTP(w, r)
return
}
}
WriteOCSError(w, r, MetaNotFound.StatusCode, "Not found", nil)
default:
WriteOCSError(w, r, MetaNotFound.StatusCode, "Not found", nil)
}
Expand Down
41 changes: 41 additions & 0 deletions internal/http/services/owncloud/ocs/notifications.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2018-2019 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

package ocs

import (
"net/http"

"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp"
)

// NotificationsHandler placeholder
type NotificationsHandler struct {
}

func (h *NotificationsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log := appctx.GetLogger(r.Context())

var head string
head, r.URL.Path = rhttp.ShiftPath(r.URL.Path)

log.Debug().Str("head", head).Str("tail", r.URL.Path).Msg("http routing")

w.WriteHeader(http.StatusOK)
}

0 comments on commit c190ea4

Please sign in to comment.