2021-05-09 14:06:06 +02:00
|
|
|
package instance
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/api"
|
2021-05-30 13:12:00 +02:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
2021-05-09 14:06:06 +02:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/router"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-05-15 11:58:11 +02:00
|
|
|
// InstanceInformationPath is for serving instance info requests
|
2021-05-09 14:06:06 +02:00
|
|
|
InstanceInformationPath = "api/v1/instance"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Module implements the ClientModule interface
|
|
|
|
type Module struct {
|
2021-05-30 13:12:00 +02:00
|
|
|
processor processing.Processor
|
2021-05-09 14:06:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// New returns a new instance information module
|
2021-12-07 13:31:39 +01:00
|
|
|
func New(processor processing.Processor) api.ClientModule {
|
2021-05-09 14:06:06 +02:00
|
|
|
return &Module{
|
|
|
|
processor: processor,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Route satisfies the ClientModule interface
|
|
|
|
func (m *Module) Route(s router.Router) error {
|
|
|
|
s.AttachHandler(http.MethodGet, InstanceInformationPath, m.InstanceInformationGETHandler)
|
2021-06-23 16:35:57 +02:00
|
|
|
s.AttachHandler(http.MethodPatch, InstanceInformationPath, m.InstanceUpdatePATCHHandler)
|
2021-05-09 14:06:06 +02:00
|
|
|
return nil
|
|
|
|
}
|