Rename api to rest
This commit is contained in:
parent
759c274950
commit
fb3fb4eeab
4 changed files with 13 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
package api
|
||||
package rest
|
||||
|
||||
import (
|
||||
"errors"
|
|
@ -1,4 +1,4 @@
|
|||
package api
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
@ -16,10 +16,10 @@ type talkgroupAPI struct {
|
|||
func (tga *talkgroupAPI) Subrouter() http.Handler {
|
||||
r := chi.NewMux()
|
||||
|
||||
r.Get("/{system:\\d+}/{id:\\d+}", tga.talkgroup)
|
||||
r.Put("/{system:\\d+}/{id:\\d+}", tga.putTalkgroup)
|
||||
r.Get("/{system:\\d+}/", tga.talkgroup)
|
||||
r.Get("/", tga.talkgroup)
|
||||
r.Get("/{system:\\d+}/{id:\\d+}", tga.get)
|
||||
r.Put("/{system:\\d+}/{id:\\d+}", tga.put)
|
||||
r.Get("/{system:\\d+}/", tga.get)
|
||||
r.Get("/", tga.get)
|
||||
|
||||
return r
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (t tgParams) ToID() talkgroups.ID {
|
|||
}
|
||||
}
|
||||
|
||||
func (tga *talkgroupAPI) talkgroup(w http.ResponseWriter, r *http.Request) {
|
||||
func (tga *talkgroupAPI) get(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
tgs := talkgroups.StoreFrom(ctx)
|
||||
|
||||
|
@ -78,7 +78,7 @@ func (tga *talkgroupAPI) talkgroup(w http.ResponseWriter, r *http.Request) {
|
|||
respond(w, r, res)
|
||||
}
|
||||
|
||||
func (tga *talkgroupAPI) putTalkgroup(w http.ResponseWriter, r *http.Request) {
|
||||
func (tga *talkgroupAPI) put(w http.ResponseWriter, r *http.Request) {
|
||||
var id tgParams
|
||||
err := decodeParams(&id, r)
|
||||
if err != nil {
|
|
@ -38,7 +38,7 @@ func (s *Server) setupRoutes() {
|
|||
s.nex.PrivateRoutes(r)
|
||||
s.auth.PrivateRoutes(r)
|
||||
s.alerter.PrivateRoutes(r)
|
||||
r.Mount("/api", s.api.Subrouter())
|
||||
r.Mount("/api", s.rest.Subrouter())
|
||||
})
|
||||
|
||||
r.Group(func(r chi.Router) {
|
||||
|
|
|
@ -7,12 +7,12 @@ import (
|
|||
"time"
|
||||
|
||||
"dynatron.me/x/stillbox/pkg/alerting"
|
||||
"dynatron.me/x/stillbox/pkg/api"
|
||||
"dynatron.me/x/stillbox/pkg/auth"
|
||||
"dynatron.me/x/stillbox/pkg/config"
|
||||
"dynatron.me/x/stillbox/pkg/database"
|
||||
"dynatron.me/x/stillbox/pkg/nexus"
|
||||
"dynatron.me/x/stillbox/pkg/notify"
|
||||
"dynatron.me/x/stillbox/pkg/rest"
|
||||
"dynatron.me/x/stillbox/pkg/sinks"
|
||||
"dynatron.me/x/stillbox/pkg/sources"
|
||||
"dynatron.me/x/stillbox/pkg/talkgroups"
|
||||
|
@ -37,7 +37,7 @@ type Server struct {
|
|||
notifier notify.Notifier
|
||||
hup chan os.Signal
|
||||
tgs talkgroups.Store
|
||||
api api.API
|
||||
rest rest.API
|
||||
}
|
||||
|
||||
func New(ctx context.Context, cfg *config.Config) (*Server, error) {
|
||||
|
@ -61,7 +61,7 @@ func New(ctx context.Context, cfg *config.Config) (*Server, error) {
|
|||
}
|
||||
|
||||
tgCache := talkgroups.NewCache()
|
||||
api := api.New()
|
||||
api := rest.New()
|
||||
|
||||
srv := &Server{
|
||||
auth: authenticator,
|
||||
|
@ -73,7 +73,7 @@ func New(ctx context.Context, cfg *config.Config) (*Server, error) {
|
|||
alerter: alerting.New(cfg.Alerting, tgCache, alerting.WithNotifier(notifier)),
|
||||
notifier: notifier,
|
||||
tgs: tgCache,
|
||||
api: api,
|
||||
rest: api,
|
||||
}
|
||||
|
||||
srv.sinks.Register("database", sinks.NewDatabaseSink(srv.db), true)
|
||||
|
|
Loading…
Reference in a new issue