Files
mattermost/api/api.go

46 lines
952 B
Go
Raw Normal View History

// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
2015-06-14 23:53:32 -08:00
// See License.txt for license information.
package api
import (
2016-02-08 07:26:10 -05:00
"net/http"
2015-06-14 23:53:32 -08:00
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
2016-01-19 10:54:19 -06:00
_ "github.com/cloudfoundry/jibber_jabber"
_ "github.com/nicksnyder/go-i18n/i18n"
2015-06-14 23:53:32 -08:00
)
func InitApi() {
r := Srv.Router.PathPrefix("/api/v1").Subrouter()
InitUser(r)
InitTeam(r)
InitChannel(r)
InitPost(r)
InitWebSocket(r)
InitFile(r)
InitCommand(r)
2015-09-10 18:32:22 -07:00
InitAdmin(r)
InitOAuth(r)
2015-09-21 14:22:23 -04:00
InitWebhook(r)
2015-10-01 15:22:04 -04:00
InitPreference(r)
2016-01-04 12:44:22 -05:00
InitLicense(r)
// 404 on any api route before web.go has a chance to serve it
Srv.Router.Handle("/api/{anything:.*}", http.HandlerFunc(Handle404))
2015-06-14 23:53:32 -08:00
2016-02-08 07:26:10 -05:00
utils.InitHTML()
2015-06-14 23:53:32 -08:00
}
func HandleEtag(etag string, w http.ResponseWriter, r *http.Request) bool {
if et := r.Header.Get(model.HEADER_ETAG_CLIENT); len(etag) > 0 {
if et == etag {
w.WriteHeader(http.StatusNotModified)
return true
}
}
return false
}