mirror of
https://github.com/owncast/owncast.git
synced 2024-12-18 07:12:33 +03:00
Spec-based API (#3653)
* chore(deps): update dependency sass to v1.74.1 * Bundle embedded web app * chore(deps): update dependency typescript to v5.4.4 * Bundle embedded web app * Commit screenshots * fix(deps): update module github.com/yuin/goldmark to v1.7.1 * chore(deps): lock file maintenance (#3662) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * Commit screenshots * chore(deps): update dependency @types/node to v20.12.5 * Bundle embedded web app * fix(deps): update module github.com/shirou/gopsutil/v3 to v3.24.3 * fix(deps): update module github.com/aws/aws-sdk-go to v1.51.17 * fix(deps): update module golang.org/x/net to v0.24.0 * fix(deps): update module golang.org/x/mod to v0.17.0 * add get admin chat clients * comment out old code * add get admin logs * add get admin warnings * add get admin chat * add post admin chat messageVisibility * add post admin chat users enabled * add post admin chat users ipban create * add post admin chat users ipban remove * add get admin chat users ipbans * chore(deps): update dependency sass-loader to v14 (#3674) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update typescript-eslint monorepo to v7 (#3680) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update dependency less-loader to v12 (#3673) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update dependency chromatic to v11 (#3669) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update dependency knip to v5 (#3672) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update nick-fields/retry action to v3 (#3678) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update dependency @types/markdown-it to v14 (#3668) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update chromaui/action action to v11 (#3666) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * Bump version number * Bundle embedded web app * Bundle embedded web app * Bundle embedded web app * fix(deps): update dependency react-virtuoso to v4.7.8 * Commit screenshots * Bundle embedded web app * Optionally disable chat rate limiter and add optional chat slur/language filter (#3681) * feat(chat): basic profanity filter. For #3139 * feat(chat): add setting for disabling chat spam protection. Closes #3523 * feat(chat): wire up the new chat slur filter to admin and chat. Closes #3139 * Bundle embedded web app * chore(deps): update peter-evans/create-or-update-comment digest to 48bb05b * fix(deps): update dependency @codemirror/language-data to v6.5.0 * Bundle embedded web app * chore(deps): update dependency css-loader to v7 (#3670) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * add get admin chat users disabled * add get admin chat users setModerator * add get admin chat users moderators * add get admin followers * chore(deps): update tj-actions/changed-files action to v44 (#3679) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Fix for copying stream key without revealing it only copies asterisks (#3663) * asterisk copy fix for #3460 * rename text to keys for consistency + linting fix * make onCopy spawn an antd message directly, remove redundant copyText function --------- Co-authored-by: Muaz Ahmad <mahmad2000@protonmail.com> * Commit updated Storybook stories * Bundle embedded web app * Commit screenshots * chore(deps): update dependency css-loader to v7.1.0 * Bundle embedded web app * chore(deps): update typescript-eslint monorepo to v7.6.0 * Bundle embedded web app * chore(deps): update dependency @types/react to v18.2.75 (#3686) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * stream offline status embed updated (#3684) * Commit screenshots * add get admin followers pending * add get admin followers blocked * add post admin followers approve * add 400 error to admin requests * add post admin emoji upload * add post admin emoji delete * add post admin config adminpass * add post admin config streamkeys * add post admin config pagecontent * add post admin config streamtitle * add post admin config streamtitle * add post admin config serversummary * add post admin config offlinemessage * add post admin config welcomemessage * add post admin config chat disable * add post admin config chat joinmessageenabled * add post admin config chat establishedusermode * add post admin config chat forbiddenusernames * add post admin config chat suggestedusernames * add post admin config video codec * add post admin config appearance * Allow react/no-danger * Commit screenshots * Change tag to self-closing since the linter complains otherwise (#3690) Co-authored-by: Muaz Ahmad <mahmad2000@protonmail.com> * Bundle embedded web app * chore(deps): update dependency css-loader to v7.1.1 (#3691) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * chore(deps): update dependency @types/node to v20.12.7 (#3688) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * Commit screenshots * chore(deps): update dependency npm to v10.5.2 * Bundle embedded web app * chore(deps): update dependency knip to v5.9.4 * Bundle embedded web app * chore(deps): update dependency typescript to v5.4.5 * Bundle embedded web app * prevent css-loader v7 renaming default to _default, needed for storybook (#3692) Co-authored-by: Muaz Ahmad <mahmad2000@protonmail.com> * Bundle embedded web app * chore(deps): update dependency cypress to v13.7.3 * Bundle embedded web app * Fix custom runtimeCaching rules, default runtimeCaching rule order (#3685) Co-authored-by: Muaz Ahmad <mahmad2000@protonmail.com> * Bundle embedded web app * Fixes for aria-live bugs (#3694) * make the aria-live text adhere to the last message's username * Wrap lastMessage in an Interweave to handle pre-encoded characters properly --------- Co-authored-by: Muaz Ahmad <mahmad2000@protonmail.com> * Bundle embedded web app * chore(deps): update dependency @types/react to v18.2.77 * Bundle embedded web app * chore(deps): update dependency @storybook/addon-styling-webpack to v1 (#3667) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * chore(deps): update dependency storybook-addon-fetch-mock to v2 (#3675) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * chore(deps): update dependency sass to v1.75.0 * Bundle embedded web app * Commit screenshots * chore(deps): update dependency sass-loader to v14.2.0 * Bundle embedded web app * fix(deps): update codemirror * add get admin webhooks * add create and delete webhooks * add get, delete, create access token endpoints * add update endpoints * Bundle embedded web app * fix(deps): update nextjs monorepo to v14.2.0 * Bundle embedded web app * fix(deps): update nextjs monorepo to v14.2.1 * Bundle embedded web app * Commit screenshots * chore(deps): update dependency @types/markdown-it to v14.0.1 * Bundle embedded web app * chore(deps): update dependency @types/react to v18.2.78 * Bundle embedded web app * add send message to connected client * add deprecated send user message * add send message to 3rd party * add send user action * add update external message visibility * add update external stream title * add external get chat messages and fixed error with chat * add external get clients * remove options request * add update logo * add update tags * add update ffmpeg path * add update server port * add update server ip * add update rtmp port * add update websocket host override * add update custom video serving endpoint * add update nsfw * add update directory enabled * Commit screenshots * add update social handles * add update stream latency level * add update stream output variants * add update s3 config * add update server url * add reset yp registration * add update external action links * add update custom styles * add update custom javascript * add get video metrics * add update hide viewer count * add update search indexing * Change fediAuth message to be more succinct (#3696) * Change fediAuth message to be more succint * Update controllers/auth/fediverse/fediverse.go for -> from --------- Co-authored-by: Gabe Kangas <gabek@real-ity.com> * Mute the 'stream ended' clip's audio (#3630) * Mute the 'stream ended' clip's audio The 'stream ended' clip plays at the at the end of every stream broadcast using owncast. It currently contains audio that peaks at -7.1db. (according to ffmpeg's volumedetect audio filter) This can result in a bad experience for viewers if the stream that they were just watching had a much lower average volume, and they had turned up their speakers or headphones to compensate. In extreme cases this could theoretically cause harm to viewers and/or their equipment. As an admin running owncast, there is no way to remove this audio *except* for patching the file. Even if you do patch the file, you need to notify your viewers to clear their browser caches if they have ever seen the clip, because offline.ts has a cache-control max-age header specifying 365 days. The caching of the previous version of this clip is out of scope of this PR. This issue is discussed in more detail in #1965. Unlike my previous attempt in #3332, which removed the audio track, this PR *mutes* the audio. Specifically, I used this ffmpeg command: ``` ffmpeg -i offline.ts -filter:a "volume=0.0" output.ts ``` There are no other modifications to the clip. * Commit updated API documentation * feat(video): make compatible muted offline clip. Rename clip as a v2 so it is not cached * Fix conflict * force add new offline file --------- Co-authored-by: vivlim <vivlim@vivl.im> Co-authored-by: Owncast <owncast@owncast.online> Co-authored-by: Gabe Kangas <gabek@real-ity.com> * Commit screenshots * chore(tests): retry cypress tests on failure * fix(deps): update module github.com/aws/aws-sdk-go to v1.51.23 * chore(deps): update dependency @types/video.js to v7.3.58 (#3705) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * fix(deps): update dependency @codemirror/language-data to v6.5.1 (#3706) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * add update message visibility * add update user status * add get moderation user details * create file for /admin/config endpoints * chore(deps): update dependency style-loader to v4 (#3703) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bundle embedded web app * chore(deps): update typescript-eslint monorepo to v7.7.0 * Bundle embedded web app * add non-api endpoints to new router * add set federation enabled * add set federation private * chore(tests): attempt to clean up test flakiness (#3710) * chore(deps): update dependency @types/react to v18.2.79 * add show federation engagement * add set federation username * add set federation go live message * add set federation blocked domains * add set discord notification configuration * add set browser notification configuration * add prometheus endpoint * add send federation message * add get federation activities * add indie auth documentation * add changes to indie auth server * Bundle embedded web app * add fediverse auth * add spam protection and slur filter * Commit screenshots * fix bug with hls endpoint * Add effect to set media session metadata (#3713) * Bundle embedded web app * chore(deps): update dependency sass-loader to v14.2.1 * Bundle embedded web app * Commit screenshots * fix(deps): update nextjs monorepo to v14.2.2 * Bundle embedded web app * Commit screenshots * fix(deps): update dependency react-virtuoso to v4.7.9 * Bundle embedded web app * chore(deps): update dependency cypress to v13.8.0 * Bundle embedded web app * Commit screenshots * chore(deps): lock file maintenance * Bundle embedded web app * add options requests and reformat operationIds * chore(go): update to go 1.22 (#3708) * chore(go): update to go 1.22 * fix: install go before running codeql to fix autobild * chore(test): explicitly set base crosscompile image * fix(test): do not point at image with incorrect version of Go * chore: troubleshoot js autoformating in workflow * Commit screenshots * add wildcard to index path * give /admin/ routes precedence * fix(deps): update dependency @fontsource/poppins to v5.0.14 * Bundle embedded web app * Bump formidable and artillery in /test/load (#3718) Removes [formidable](https://github.com/node-formidable/formidable). It's no longer used after updating ancestor dependency [artillery](https://github.com/artilleryio/artillery). These dependencies need to be updated together. Removes `formidable` Updates `artillery` from 2.0.2 to 2.0.10 - [Release notes](https://github.com/artilleryio/artillery/releases) - [Commits](https://github.com/artilleryio/artillery/compare/artillery-2.0.2...artillery-2.0.10) --- updated-dependencies: - dependency-name: formidable dependency-type: indirect - dependency-name: artillery dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Commit screenshots * chore(deps): update peter-evans/create-or-update-comment digest to da12db3 * fix(deps): update dependency react-virtuoso to v4.7.10 * add verbose logging and update handler precedence * Bundle embedded web app * Commit screenshots * chore(deps): update golangci/golangci-lint-action action to v5 (#3722) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update typescript-eslint monorepo to v7.7.1 * Bundle embedded web app * Commit screenshots * chore(deps): update dependency knip to v5.10.0 * Bundle embedded web app * add federation routers * updated comments to pass linter * fix bug with mount * fix linting errors * add router logs to log files * update emoji dir * fixed linting error --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Owncast <owncast@owncast.online> Co-authored-by: Gabe Kangas <gabek@real-ity.com> Co-authored-by: mahmed2000 <49453542+mahmed2000@users.noreply.github.com> Co-authored-by: Muaz Ahmad <mahmad2000@protonmail.com> Co-authored-by: Jeet Chawda <68128367+Jeetch8@users.noreply.github.com> Co-authored-by: Vivian Lim ⭐ <1565930+vivlim@users.noreply.github.com> Co-authored-by: vivlim <vivlim@vivl.im> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
1d49801a27
commit
2513b15b40
24 changed files with 12860 additions and 429 deletions
|
@ -17,7 +17,6 @@ func Start(datastore *data.Datastore) {
|
|||
persistence.Setup(datastore)
|
||||
workerpool.InitOutboundWorkerPool()
|
||||
inbox.InitInboxWorkerPool()
|
||||
StartRouter()
|
||||
|
||||
// Generate the keys for signing federated activity if needed.
|
||||
if data.GetPrivateKey() == "" {
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package activitypub
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/activitypub/controllers"
|
||||
"github.com/owncast/owncast/router/middleware"
|
||||
)
|
||||
|
||||
// StartRouter will start the federation specific http router.
|
||||
func StartRouter() {
|
||||
// WebFinger
|
||||
http.HandleFunc("/.well-known/webfinger", controllers.WebfingerHandler)
|
||||
|
||||
// Host Metadata
|
||||
http.HandleFunc("/.well-known/host-meta", controllers.HostMetaController)
|
||||
|
||||
// Nodeinfo v1
|
||||
http.HandleFunc("/.well-known/nodeinfo", controllers.NodeInfoController)
|
||||
|
||||
// x-nodeinfo v2
|
||||
http.HandleFunc("/.well-known/x-nodeinfo2", controllers.XNodeInfo2Controller)
|
||||
|
||||
// Nodeinfo v2
|
||||
http.HandleFunc("/nodeinfo/2.0", controllers.NodeInfoV2Controller)
|
||||
|
||||
// Instance details
|
||||
http.HandleFunc("/api/v1/instance", controllers.InstanceV1Controller)
|
||||
|
||||
// Single ActivityPub Actor
|
||||
http.HandleFunc("/federation/user/", middleware.RequireActivityPubOrRedirect(controllers.ActorHandler))
|
||||
|
||||
// Single AP object
|
||||
http.HandleFunc("/federation/", middleware.RequireActivityPubOrRedirect(controllers.ObjectHandler))
|
||||
}
|
|
@ -13,18 +13,18 @@ import (
|
|||
func HandleAuthEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodGet {
|
||||
// Require the GET request for IndieAuth to be behind admin login.
|
||||
f := middleware.RequireAdminAuth(handleAuthEndpointGet)
|
||||
f := middleware.RequireAdminAuth(HandleAuthEndpointGet)
|
||||
f(w, r)
|
||||
return
|
||||
} else if r.Method == http.MethodPost {
|
||||
handleAuthEndpointPost(w, r)
|
||||
HandleAuthEndpointPost(w, r)
|
||||
} else {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func handleAuthEndpointGet(w http.ResponseWriter, r *http.Request) {
|
||||
func HandleAuthEndpointGet(w http.ResponseWriter, r *http.Request) {
|
||||
clientID := r.URL.Query().Get("client_id")
|
||||
redirectURI := r.URL.Query().Get("redirect_uri")
|
||||
codeChallenge := r.URL.Query().Get("code_challenge")
|
||||
|
@ -57,7 +57,7 @@ func handleAuthEndpointGet(w http.ResponseWriter, r *http.Request) {
|
|||
http.Redirect(w, r, u.String(), http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
func handleAuthEndpointPost(w http.ResponseWriter, r *http.Request) {
|
||||
func HandleAuthEndpointPost(w http.ResponseWriter, r *http.Request) {
|
||||
if err := r.ParseForm(); err != nil {
|
||||
controllers.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
|
|
4
go.mod
4
go.mod
|
@ -60,10 +60,12 @@ require github.com/SherClockHolmes/webpush-go v1.3.0
|
|||
|
||||
require (
|
||||
github.com/andybalholm/brotli v1.0.5 // indirect
|
||||
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-test/deep v1.0.4 // indirect
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||
github.com/google/uuid v1.5.0 // indirect
|
||||
github.com/gorilla/css v1.0.0 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/oschwald/maxminddb-golang v1.11.0 // indirect
|
||||
|
@ -77,8 +79,10 @@ require (
|
|||
github.com/CAFxX/httpcompression v0.0.9
|
||||
github.com/TwiN/go-away v1.6.13
|
||||
github.com/andybalholm/cascadia v1.3.2
|
||||
github.com/go-chi/chi/v5 v5.0.12
|
||||
github.com/jellydator/ttlcache/v3 v3.2.0
|
||||
github.com/mssola/user_agent v0.6.0
|
||||
github.com/oapi-codegen/runtime v1.1.1
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/yuin/goldmark-emoji v1.0.2
|
||||
gopkg.in/evanphx/json-patch.v5 v5.9.0
|
||||
|
|
18
go.sum
18
go.sum
|
@ -1,5 +1,6 @@
|
|||
github.com/CAFxX/httpcompression v0.0.9 h1:0ue2X8dOLEpxTm8tt+OdHcgA+gbDge0OqFQWGKSqgrg=
|
||||
github.com/CAFxX/httpcompression v0.0.9/go.mod h1:XX8oPZA+4IDcfZ0A71Hz0mZsv/YJOgYygkFhizVPilM=
|
||||
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
|
||||
github.com/SherClockHolmes/webpush-go v1.3.0 h1:CAu3FvEE9QS4drc3iKNgpBWFfGqNthKlZhp5QpYnu6k=
|
||||
github.com/SherClockHolmes/webpush-go v1.3.0/go.mod h1:AxRHmJuYwKGG1PVgYzToik1lphQvDnqFYDqimHvwhIw=
|
||||
github.com/TwiN/go-away v1.6.13 h1:aB6l/FPXmA5ds+V7I9zdhxzpsLLUvVtEuS++iU/ZmgE=
|
||||
|
@ -12,18 +13,23 @@ github.com/aws/aws-sdk-go v1.50.33 h1:/SKPJ7ZVPCFOYZyTKo5YdjeUEeOn2J2M0qfDTXWAoE
|
|||
github.com/aws/aws-sdk-go v1.50.33/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
|
||||
github.com/aws/aws-sdk-go v1.51.17 h1:Cfa40lCdjv9OxC3X1Ks3a6O1Tu3gOANSyKHOSw/zuWU=
|
||||
github.com/aws/aws-sdk-go v1.51.17/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
|
||||
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
|
||||
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
|
||||
github.com/aws/aws-sdk-go v1.51.23 h1:/3TEdsEE/aHmdKGw2NrOp7Sdea76zfffGkTTSXTsDxY=
|
||||
github.com/aws/aws-sdk-go v1.51.23/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
|
||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/dave/jennifer v1.3.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
|
||||
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/go-fed/httpsig v0.1.1-0.20190914113940-c2de3672e5b5/go.mod h1:T56HUNYZUQ1AGUzhAYPugZfp36sKApVnGBgKlIY+aIE=
|
||||
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
|
||||
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
|
||||
|
@ -41,6 +47,8 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
|
||||
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
|
||||
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
|
||||
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
||||
|
@ -55,6 +63,7 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw
|
|||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
|
||||
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
|
||||
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
|
||||
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
|
@ -83,6 +92,8 @@ github.com/nakabonne/tstorage v0.3.6 h1:usp7pTohax8mynnFiUSUQ2QVBCKLCkYx3gmb3+rJ
|
|||
github.com/nakabonne/tstorage v0.3.6/go.mod h1:1xUrK3s1MXSlU6dn96xHerHx/MdO4BGmsAHEUbsaOxU=
|
||||
github.com/nareix/joy5 v0.0.0-20210317075623-2c912ca30590 h1:PnxRU8L8Y2q82vFC2QdNw23Dm2u6WrjecIdpXjiYbXM=
|
||||
github.com/nareix/joy5 v0.0.0-20210317075623-2c912ca30590/go.mod h1:XmAOs6UJXpNXRwKk+KY/nv5kL6xXYXyellk+A1pTlko=
|
||||
github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro=
|
||||
github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg=
|
||||
github.com/oschwald/geoip2-golang v1.9.0 h1:uvD3O6fXAXs+usU+UGExshpdP13GAqp4GBrzN7IgKZc=
|
||||
github.com/oschwald/geoip2-golang v1.9.0/go.mod h1:BHK6TvDyATVQhKNbQBdrj9eAvuwOMi2zSFXizL3K81Y=
|
||||
github.com/oschwald/maxminddb-golang v1.11.0 h1:aSXMqYR/EPNjGE8epgqwDay+P30hCBZIveY0WZbAWh0=
|
||||
|
@ -124,6 +135,7 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
|
|||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/spf13/cobra v0.0.4-0.20190109003409-7547e83b2d85/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/pflag v1.0.4-0.20181223182923-24fa6976df40/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
|
@ -203,8 +215,6 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
|
@ -213,8 +223,8 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX
|
|||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
|
||||
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
|
|
306
handler/admin.go
Normal file
306
handler/admin.go
Normal file
|
@ -0,0 +1,306 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/controllers"
|
||||
"github.com/owncast/owncast/controllers/admin"
|
||||
"github.com/owncast/owncast/handler/generated"
|
||||
"github.com/owncast/owncast/router/middleware"
|
||||
)
|
||||
|
||||
func (*ServerInterfaceImpl) StatusAdmin(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.Status)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) StatusAdminOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.Status)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) DisconnectInboundConnection(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.DisconnectInboundConnection)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) DisconnectInboundConnectionOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.DisconnectInboundConnection)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetServerConfig)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetServerConfigOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetServerConfig)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetViewersOverTime(w http.ResponseWriter, r *http.Request, params generated.GetViewersOverTimeParams) {
|
||||
middleware.RequireAdminAuth(admin.GetViewersOverTime)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetViewersOverTimeOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetViewersOverTime)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetActiveViewers(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetActiveViewers)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetActiveViewersOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetActiveViewers)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetHardwareStats(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetHardwareStats)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetHardwareStatsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetHardwareStats)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetConnectedChatClients(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetConnectedChatClients)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetConnectedChatClientsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetConnectedChatClients)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetChatMessagesAdmin(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetChatMessages)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetChatMessagesAdminOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetChatMessages)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UpdateMessageVisibilityAdmin(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UpdateMessageVisibility)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UpdateMessageVisibilityAdminOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UpdateMessageVisibility)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UpdateUserEnabledAdmin(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UpdateUserEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UpdateUserEnabledAdminOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UpdateUserEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetDisabledUsers(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetDisabledUsers)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetDisabledUsersOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetDisabledUsers)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) BanIPAddress(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.BanIPAddress)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) BanIPAddressOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.BanIPAddress)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UnbanIPAddress(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UnBanIPAddress)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UnbanIPAddressOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UnBanIPAddress)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetIPAddressBans(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetIPAddressBans)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetIPAddressBansOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetIPAddressBans)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UpdateUserModerator(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UpdateUserModerator)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UpdateUserModeratorOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UpdateUserModerator)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetModerators(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetModerators)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetModeratorsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetModerators)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetLogs(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetLogs)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetLogsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetLogs)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetWarnings(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetWarnings)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetWarningsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetWarnings)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetFollowersAdmin(w http.ResponseWriter, r *http.Request, params generated.GetFollowersAdminParams) {
|
||||
middleware.RequireAdminAuth(middleware.HandlePagination(controllers.GetFollowers))(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetFollowersAdminOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(middleware.HandlePagination(controllers.GetFollowers))(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetPendingFollowRequests(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetPendingFollowRequests)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetPendingFollowRequestsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetPendingFollowRequests)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetBlockedAndRejectedFollowers(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetBlockedAndRejectedFollowers)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetBlockedAndRejectedFollowersOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetBlockedAndRejectedFollowers)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ApproveFollower(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.ApproveFollower)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ApproveFollowerOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.ApproveFollower)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UploadCustomEmoji(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UploadCustomEmoji)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UploadCustomEmojiOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.UploadCustomEmoji)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) DeleteCustomEmoji(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.DeleteCustomEmoji)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) DeleteCustomEmojiOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.DeleteCustomEmoji)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetWebhooks(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetWebhooks)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetWebhooksOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetWebhooks)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) DeleteWebhook(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.DeleteWebhook)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) DeleteWebhookOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.DeleteWebhook)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) CreateWebhook(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.CreateWebhook)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) CreateWebhookOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.CreateWebhook)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetExternalAPIUsers(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetExternalAPIUsers)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetExternalAPIUsersOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetExternalAPIUsers)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) DeleteExternalAPIUser(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.DeleteExternalAPIUser)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) DeleteExternalAPIUserOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.DeleteExternalAPIUser)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) CreateExternalAPIUser(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.CreateExternalAPIUser)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) CreateExternalAPIUserOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.CreateExternalAPIUser)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) AutoUpdateOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.AutoUpdateOptions)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) AutoUpdateOptionsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.AutoUpdateOptions)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) AutoUpdateStart(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.AutoUpdateStart)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) AutoUpdateStartOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.AutoUpdateStart)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) AutoUpdateForceQuit(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.AutoUpdateForceQuit)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) AutoUpdateForceQuitOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.AutoUpdateForceQuit)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ResetYPRegistration(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.ResetYPRegistration)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ResetYPRegistrationOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.ResetYPRegistration)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetVideoPlaybackMetrics(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetVideoPlaybackMetrics)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetVideoPlaybackMetricsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.GetVideoPlaybackMetrics)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SendFederatedMessage(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SendFederatedMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SendFederatedMessageOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SendFederatedMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetFederatedActions(w http.ResponseWriter, r *http.Request, params generated.GetFederatedActionsParams) {
|
||||
middleware.RequireAdminAuth(middleware.HandlePagination(admin.GetFederatedActions))(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetFederatedActionsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(middleware.HandlePagination(admin.GetFederatedActions))(w, r)
|
||||
}
|
34
handler/auth.go
Normal file
34
handler/auth.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/controllers/auth/fediverse"
|
||||
"github.com/owncast/owncast/controllers/auth/indieauth"
|
||||
"github.com/owncast/owncast/handler/generated"
|
||||
"github.com/owncast/owncast/router/middleware"
|
||||
)
|
||||
|
||||
func (*ServerInterfaceImpl) StartIndieAuthFlow(w http.ResponseWriter, r *http.Request, params generated.StartIndieAuthFlowParams) {
|
||||
middleware.RequireUserAccessToken(indieauth.StartAuthFlow)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) HandleIndieAuthRedirect(w http.ResponseWriter, r *http.Request, params generated.HandleIndieAuthRedirectParams) {
|
||||
indieauth.HandleRedirect(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) HandleIndieAuthEndpointGet(w http.ResponseWriter, r *http.Request, params generated.HandleIndieAuthEndpointGetParams) {
|
||||
middleware.RequireAdminAuth(indieauth.HandleAuthEndpointGet)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) HandleIndieAuthEndpointPost(w http.ResponseWriter, r *http.Request) {
|
||||
indieauth.HandleAuthEndpointPost(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) RegisterFediverseOTPRequest(w http.ResponseWriter, r *http.Request, params generated.RegisterFediverseOTPRequestParams) {
|
||||
middleware.RequireUserAccessToken(fediverse.RegisterFediverseOTPRequest)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) VerifyFediverseOTPRequest(w http.ResponseWriter, r *http.Request) {
|
||||
fediverse.VerifyFediverseOTPRequest(w, r)
|
||||
}
|
368
handler/config.go
Normal file
368
handler/config.go
Normal file
|
@ -0,0 +1,368 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/controllers/admin"
|
||||
"github.com/owncast/owncast/router/middleware"
|
||||
)
|
||||
|
||||
func (*ServerInterfaceImpl) SetAdminPassword(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetAdminPassword)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetAdminPasswordOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetAdminPassword)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetStreamKeys(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetStreamKeys)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetStreamKeysOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetStreamKeys)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetExtraPageContent(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetExtraPageContent)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetExtraPageContentOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetExtraPageContent)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetStreamTitle(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetStreamTitle)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetStreamTitleOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetStreamTitle)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetServerName(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetServerName)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetServerNameOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetServerName)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetServerSummary(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetServerSummary)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetServerSummaryOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetServerSummary)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetCustomOfflineMessage(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetCustomOfflineMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetCustomOfflineMessageOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetCustomOfflineMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetServerWelcomeMessage(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetServerWelcomeMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetServerWelcomeMessageOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetServerWelcomeMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetChatDisabled(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetChatDisabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetChatDisabledOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetChatDisabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetChatJoinMessagesEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetChatJoinMessagesEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetChatJoinMessagesEnabledOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetChatJoinMessagesEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetEnableEstablishedChatUserMode(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetEnableEstablishedChatUserMode)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetEnableEstablishedChatUserModeOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetEnableEstablishedChatUserMode)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetForbiddenUsernameList(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetForbiddenUsernameList)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetForbiddenUsernameListOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetForbiddenUsernameList)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetSuggestedUsernameList(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetSuggestedUsernameList)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetSuggestedUsernameListOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetSuggestedUsernameList)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetChatSpamProtectionEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetChatSpamProtectionEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetChatSpamProtectionEnabledOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetChatSpamProtectionEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetChatSlurFilterEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetChatSlurFilterEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetChatSlurFilterEnabledOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetChatSlurFilterEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetVideoCodec(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetVideoCodec)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetVideoCodecOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetVideoCodec)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetStreamLatencyLevel(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetStreamLatencyLevel)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetStreamLatencyLevelOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetStreamLatencyLevel)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetStreamOutputVariants)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetStreamOutputVariantsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetStreamOutputVariants)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetCustomColorVariableValues(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetCustomColorVariableValues)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetCustomColorVariableValuesOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetCustomColorVariableValues)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetLogo(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetLogo)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetLogoOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetLogo)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetTags(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetTags)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetTagsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetTags)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFfmpegPath(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFfmpegPath)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFfmpegPathOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFfmpegPath)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetWebServerPort(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetWebServerPort)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetWebServerPortOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetWebServerPort)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetWebServerIP(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetWebServerIP)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetWebServerIPOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetWebServerIP)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetRTMPServerPort(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetRTMPServerPort)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetRTMPServerPortOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetRTMPServerPort)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetSocketHostOverride(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetSocketHostOverride)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetSocketHostOverrideOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetSocketHostOverride)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetVideoServingEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetVideoServingEndpoint)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetVideoServingEndpointOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetVideoServingEndpoint)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetNSFW(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetNSFW)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetNSFWOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetNSFW)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetDirectoryEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetDirectoryEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetDirectoryEnabledOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetDirectoryEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetSocialHandles(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetSocialHandles)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetSocialHandlesOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetSocialHandles)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetS3Configuration(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetS3Configuration)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetS3ConfigurationOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetS3Configuration)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetServerURL(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetServerURL)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetServerURLOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetServerURL)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetExternalActions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetExternalActions)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetExternalActionsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetExternalActions)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetCustomStyles(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetCustomStyles)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetCustomStylesOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetCustomStyles)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetCustomJavascript(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetCustomJavascript)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetCustomJavascriptOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetCustomJavascript)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetHideViewerCount(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetHideViewerCount)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetHideViewerCountOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetHideViewerCount)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetDisableSearchIndexing(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetDisableSearchIndexing)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetDisableSearchIndexingOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetDisableSearchIndexing)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationEnabledOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationActivityPrivate(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationActivityPrivate)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationActivityPrivateOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationActivityPrivate)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationShowEngagement(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationShowEngagement)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationShowEngagementOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationShowEngagement)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationUsername(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationUsername)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationUsernameOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationUsername)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationGoLiveMessage(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationGoLiveMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationGoLiveMessageOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationGoLiveMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationBlockDomains(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationBlockDomains)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetFederationBlockDomainsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetFederationBlockDomains)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetDiscordNotificationConfiguration(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetDiscordNotificationConfiguration)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetDiscordNotificationConfigurationOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetDiscordNotificationConfiguration)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetBrowserNotificationConfiguration(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetBrowserNotificationConfiguration)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SetBrowserNotificationConfigurationOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireAdminAuth(admin.SetBrowserNotificationConfiguration)(w, r)
|
||||
}
|
1342
handler/generated/generated-types.gen.go
Normal file
1342
handler/generated/generated-types.gen.go
Normal file
File diff suppressed because it is too large
Load diff
6297
handler/generated/generated.gen.go
Normal file
6297
handler/generated/generated.gen.go
Normal file
File diff suppressed because it is too large
Load diff
88
handler/handler.go
Normal file
88
handler/handler.go
Normal file
|
@ -0,0 +1,88 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/controllers"
|
||||
"github.com/owncast/owncast/controllers/admin"
|
||||
"github.com/owncast/owncast/handler/generated"
|
||||
"github.com/owncast/owncast/router/middleware"
|
||||
"github.com/owncast/owncast/yp"
|
||||
)
|
||||
|
||||
type ServerInterfaceImpl struct{}
|
||||
|
||||
// ensure ServerInterfaceImpl implements ServerInterface.
|
||||
var _ generated.ServerInterface = &ServerInterfaceImpl{}
|
||||
|
||||
func New() *ServerInterfaceImpl {
|
||||
return &ServerInterfaceImpl{}
|
||||
}
|
||||
|
||||
func (s *ServerInterfaceImpl) Handler() http.Handler {
|
||||
return generated.Handler(s)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetStatus(w http.ResponseWriter, r *http.Request) {
|
||||
controllers.GetStatus(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetCustomEmojiList(w http.ResponseWriter, r *http.Request) {
|
||||
controllers.GetCustomEmojiList(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetChatMessages(w http.ResponseWriter, r *http.Request, params generated.GetChatMessagesParams) {
|
||||
middleware.RequireUserAccessToken(controllers.GetChatMessages)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) RegisterAnonymousChatUser(w http.ResponseWriter, r *http.Request, params generated.RegisterAnonymousChatUserParams) {
|
||||
controllers.RegisterAnonymousChatUser(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) RegisterAnonymousChatUserOptions(w http.ResponseWriter, r *http.Request) {
|
||||
controllers.RegisterAnonymousChatUser(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UpdateMessageVisibility(w http.ResponseWriter, r *http.Request, params generated.UpdateMessageVisibilityParams) {
|
||||
middleware.RequireUserModerationScopeAccesstoken(admin.UpdateMessageVisibility)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) UpdateUserEnabled(w http.ResponseWriter, r *http.Request, params generated.UpdateUserEnabledParams) {
|
||||
middleware.RequireUserModerationScopeAccesstoken(admin.UpdateUserEnabled)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetWebConfig(w http.ResponseWriter, r *http.Request) {
|
||||
controllers.GetWebConfig(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetYPResponse(w http.ResponseWriter, r *http.Request) {
|
||||
yp.GetYPResponse(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetAllSocialPlatforms(w http.ResponseWriter, r *http.Request) {
|
||||
controllers.GetAllSocialPlatforms(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetVideoStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
|
||||
controllers.GetVideoStreamOutputVariants(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) Ping(w http.ResponseWriter, r *http.Request) {
|
||||
controllers.Ping(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) RemoteFollow(w http.ResponseWriter, r *http.Request) {
|
||||
controllers.RemoteFollow(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetFollowers(w http.ResponseWriter, r *http.Request, params generated.GetFollowersParams) {
|
||||
middleware.HandlePagination(controllers.GetFollowers)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ReportPlaybackMetrics(w http.ResponseWriter, r *http.Request) {
|
||||
controllers.ReportPlaybackMetrics(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) RegisterForLiveNotifications(w http.ResponseWriter, r *http.Request, params generated.RegisterForLiveNotificationsParams) {
|
||||
middleware.RequireUserAccessToken(controllers.RegisterForLiveNotifications)(w, r)
|
||||
}
|
123
handler/integrations.go
Normal file
123
handler/integrations.go
Normal file
|
@ -0,0 +1,123 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/controllers"
|
||||
"github.com/owncast/owncast/controllers/admin"
|
||||
"github.com/owncast/owncast/core/user"
|
||||
"github.com/owncast/owncast/router/middleware"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
func (*ServerInterfaceImpl) SendSystemMessage(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendSystemMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SendSystemMessageOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendSystemMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SendSystemMessageToConnectedClient(w http.ResponseWriter, r *http.Request, clientId int) {
|
||||
// doing this hack to make the new system work with the old system
|
||||
r.Header[utils.RestURLPatternHeaderKey] = []string{`/api/integrations/chat/system/client/{clientId}`}
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendSystemMessageToConnectedClient)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SendSystemMessageToConnectedClientOptions(w http.ResponseWriter, r *http.Request, clientId int) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendSystemMessageToConnectedClient)(w, r)
|
||||
}
|
||||
|
||||
// Deprecated.
|
||||
func (*ServerInterfaceImpl) SendUserMessage(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendChatMessages, admin.SendUserMessage)(w, r)
|
||||
}
|
||||
|
||||
// Deprecated.
|
||||
func (*ServerInterfaceImpl) SendUserMessageOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendChatMessages, admin.SendUserMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SendIntegrationChatMessage(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendChatMessages, admin.SendIntegrationChatMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SendIntegrationChatMessageOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendChatMessages, admin.SendIntegrationChatMessage)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SendChatAction(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendChatAction)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) SendChatActionOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendChatAction)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ExternalUpdateMessageVisibility(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalUpdateMessageVisibility)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ExternalUpdateMessageVisibilityOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalUpdateMessageVisibility)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ExternalSetStreamTitle(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalSetStreamTitle)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ExternalSetStreamTitleOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalSetStreamTitle)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ExternalGetChatMessages(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, controllers.ExternalGetChatMessages)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ExternalGetChatMessagesOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, controllers.ExternalGetChatMessages)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ExternalGetConnectedChatClients(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalGetConnectedChatClients)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) ExternalGetConnectedChatClientsOptions(w http.ResponseWriter, r *http.Request) {
|
||||
middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalGetConnectedChatClients)(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) GetPrometheusAPI(w http.ResponseWriter, r *http.Request) {
|
||||
// might need to bring this out of the codegen
|
||||
middleware.RequireAdminAuth(func(w http.ResponseWriter, r *http.Request) {
|
||||
promhttp.Handler()
|
||||
})(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) PostPrometheusAPI(w http.ResponseWriter, r *http.Request) {
|
||||
// might need to bring this out of the codegen
|
||||
middleware.RequireAdminAuth(func(w http.ResponseWriter, r *http.Request) {
|
||||
promhttp.Handler()
|
||||
})(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) PutPrometheusAPI(w http.ResponseWriter, r *http.Request) {
|
||||
// might need to bring this out of the codegen
|
||||
middleware.RequireAdminAuth(func(w http.ResponseWriter, r *http.Request) {
|
||||
promhttp.Handler()
|
||||
})(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) DeletePrometheusAPI(w http.ResponseWriter, r *http.Request) {
|
||||
// might need to bring this out of the codegen
|
||||
middleware.RequireAdminAuth(func(w http.ResponseWriter, r *http.Request) {
|
||||
promhttp.Handler()
|
||||
})(w, r)
|
||||
}
|
||||
|
||||
func (*ServerInterfaceImpl) OptionsPrometheusAPI(w http.ResponseWriter, r *http.Request) {
|
||||
// might need to bring this out of the codegen
|
||||
middleware.RequireAdminAuth(func(w http.ResponseWriter, r *http.Request) {
|
||||
promhttp.Handler()
|
||||
})(w, r)
|
||||
}
|
13
handler/moderation.go
Normal file
13
handler/moderation.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/controllers/moderation"
|
||||
"github.com/owncast/owncast/handler/generated"
|
||||
"github.com/owncast/owncast/router/middleware"
|
||||
)
|
||||
|
||||
func (*ServerInterfaceImpl) GetUserDetails(w http.ResponseWriter, r *http.Request, userId string, params generated.GetUserDetailsParams) {
|
||||
middleware.RequireUserModerationScopeAccesstoken(moderation.GetUserDetails)(w, r)
|
||||
}
|
2
main.go
2
main.go
|
@ -105,7 +105,7 @@ func main() {
|
|||
|
||||
go metrics.Start(core.GetStatus)
|
||||
|
||||
if err := router.Start(); err != nil {
|
||||
if err := router.Start(*enableVerboseLogging); err != nil {
|
||||
log.Fatalln("failed to start/run the router", err)
|
||||
}
|
||||
}
|
||||
|
|
457
router/router.go
457
router/router.go
|
@ -3,420 +3,72 @@ package router
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/CAFxX/httpcompression"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/go-chi/chi/v5"
|
||||
chiMW "github.com/go-chi/chi/v5/middleware"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/h2c"
|
||||
|
||||
"github.com/owncast/owncast/activitypub"
|
||||
apControllers "github.com/owncast/owncast/activitypub/controllers"
|
||||
"github.com/owncast/owncast/config"
|
||||
"github.com/owncast/owncast/controllers"
|
||||
"github.com/owncast/owncast/controllers/admin"
|
||||
fediverseauth "github.com/owncast/owncast/controllers/auth/fediverse"
|
||||
"github.com/owncast/owncast/controllers/auth/indieauth"
|
||||
"github.com/owncast/owncast/controllers/moderation"
|
||||
"github.com/owncast/owncast/core/chat"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/core/user"
|
||||
"github.com/owncast/owncast/handler"
|
||||
"github.com/owncast/owncast/router/middleware"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/owncast/owncast/yp"
|
||||
)
|
||||
|
||||
// Start starts the router for the http, ws, and rtmp.
|
||||
func Start() error {
|
||||
// The primary web app.
|
||||
http.HandleFunc("/", controllers.IndexHandler)
|
||||
func Start(enableVerboseLogging bool) error {
|
||||
// @behlers New Router
|
||||
r := chi.NewRouter()
|
||||
|
||||
// The admin web app.
|
||||
http.HandleFunc("/admin/", middleware.RequireAdminAuth(controllers.IndexHandler))
|
||||
// Middlewares
|
||||
if enableVerboseLogging {
|
||||
r.Use(chiMW.RequestLogger(&chiMW.DefaultLogFormatter{Logger: log.StandardLogger(), NoColor: true}))
|
||||
}
|
||||
r.Use(chiMW.Recoverer)
|
||||
|
||||
// Images
|
||||
http.HandleFunc("/thumbnail.jpg", controllers.GetThumbnail)
|
||||
http.HandleFunc("/preview.gif", controllers.GetPreview)
|
||||
http.HandleFunc("/logo", controllers.GetLogo)
|
||||
addStaticFileEndpoints(r)
|
||||
|
||||
// Custom Javascript
|
||||
http.HandleFunc("/customjavascript", controllers.ServeCustomJavascript)
|
||||
// websocket
|
||||
r.HandleFunc("/ws", chat.HandleClientConnection)
|
||||
|
||||
// Return a single emoji image.
|
||||
http.HandleFunc(config.EmojiDir, controllers.GetCustomEmojiImage)
|
||||
|
||||
// return the logo
|
||||
|
||||
// return a logo that's compatible with external social networks
|
||||
http.HandleFunc("/logo/external", controllers.GetCompatibleLogo)
|
||||
|
||||
// robots.txt
|
||||
http.HandleFunc("/robots.txt", controllers.GetRobotsDotTxt)
|
||||
|
||||
// status of the system
|
||||
http.HandleFunc("/api/status", controllers.GetStatus)
|
||||
|
||||
// custom emoji supported in the chat
|
||||
http.HandleFunc("/api/emoji", controllers.GetCustomEmojiList)
|
||||
|
||||
// chat rest api
|
||||
http.HandleFunc("/api/chat", middleware.RequireUserAccessToken(controllers.GetChatMessages))
|
||||
|
||||
// web config api
|
||||
http.HandleFunc("/api/config", controllers.GetWebConfig)
|
||||
|
||||
// return the YP protocol data
|
||||
http.HandleFunc("/api/yp", yp.GetYPResponse)
|
||||
|
||||
// list of all social platforms
|
||||
http.HandleFunc("/api/socialplatforms", controllers.GetAllSocialPlatforms)
|
||||
|
||||
// return the list of video variants available
|
||||
http.HandleFunc("/api/video/variants", controllers.GetVideoStreamOutputVariants)
|
||||
|
||||
// tell the backend you're an active viewer
|
||||
http.HandleFunc("/api/ping", controllers.Ping)
|
||||
|
||||
// register a new chat user
|
||||
http.HandleFunc("/api/chat/register", controllers.RegisterAnonymousChatUser)
|
||||
|
||||
// return remote follow details
|
||||
http.HandleFunc("/api/remotefollow", controllers.RemoteFollow)
|
||||
|
||||
// return followers
|
||||
http.HandleFunc("/api/followers", middleware.HandlePagination(controllers.GetFollowers))
|
||||
|
||||
// save client video playback metrics
|
||||
http.HandleFunc("/api/metrics/playback", controllers.ReportPlaybackMetrics)
|
||||
|
||||
// Register for notifications
|
||||
http.HandleFunc("/api/notifications/register", middleware.RequireUserAccessToken(controllers.RegisterForLiveNotifications))
|
||||
|
||||
// Authenticated admin requests
|
||||
|
||||
// Current inbound broadcaster
|
||||
http.HandleFunc("/api/admin/status", middleware.RequireAdminAuth(admin.Status))
|
||||
// serve files
|
||||
fs := http.FileServer(http.Dir(config.PublicFilesPath))
|
||||
r.Handle("/public/*", http.StripPrefix("/public/", fs))
|
||||
|
||||
// Return HLS video
|
||||
http.HandleFunc("/hls/", controllers.HandleHLSRequest)
|
||||
r.HandleFunc("/hls/*", controllers.HandleHLSRequest)
|
||||
|
||||
// Disconnect inbound stream
|
||||
http.HandleFunc("/api/admin/disconnect", middleware.RequireAdminAuth(admin.DisconnectInboundConnection))
|
||||
// The admin web app.
|
||||
r.HandleFunc("/admin/*", middleware.RequireAdminAuth(controllers.IndexHandler))
|
||||
|
||||
// Server config
|
||||
http.HandleFunc("/api/admin/serverconfig", middleware.RequireAdminAuth(admin.GetServerConfig))
|
||||
// Single ActivityPub Actor
|
||||
r.HandleFunc("/federation/user/*", middleware.RequireActivityPubOrRedirect(apControllers.ActorHandler))
|
||||
|
||||
// Get viewer count over time
|
||||
http.HandleFunc("/api/admin/viewersOverTime", middleware.RequireAdminAuth(admin.GetViewersOverTime))
|
||||
// Single AP object
|
||||
r.HandleFunc("/federation/*", middleware.RequireActivityPubOrRedirect(apControllers.ObjectHandler))
|
||||
|
||||
// Get active viewers
|
||||
http.HandleFunc("/api/admin/viewers", middleware.RequireAdminAuth(admin.GetActiveViewers))
|
||||
// The primary web app.
|
||||
r.HandleFunc("/*", controllers.IndexHandler)
|
||||
|
||||
// Get hardware stats
|
||||
http.HandleFunc("/api/admin/hardwarestats", middleware.RequireAdminAuth(admin.GetHardwareStats))
|
||||
|
||||
// Get a a detailed list of currently connected chat clients
|
||||
http.HandleFunc("/api/admin/chat/clients", middleware.RequireAdminAuth(admin.GetConnectedChatClients))
|
||||
|
||||
// Get all logs
|
||||
http.HandleFunc("/api/admin/logs", middleware.RequireAdminAuth(admin.GetLogs))
|
||||
|
||||
// Get warning/error logs
|
||||
http.HandleFunc("/api/admin/logs/warnings", middleware.RequireAdminAuth(admin.GetWarnings))
|
||||
|
||||
// Get all chat messages for the admin, unfiltered.
|
||||
http.HandleFunc("/api/admin/chat/messages", middleware.RequireAdminAuth(admin.GetChatMessages))
|
||||
|
||||
// Update chat message visibility
|
||||
http.HandleFunc("/api/admin/chat/messagevisibility", middleware.RequireAdminAuth(admin.UpdateMessageVisibility))
|
||||
|
||||
// Enable/disable a user
|
||||
http.HandleFunc("/api/admin/chat/users/setenabled", middleware.RequireAdminAuth(admin.UpdateUserEnabled))
|
||||
|
||||
// Ban/unban an IP address
|
||||
http.HandleFunc("/api/admin/chat/users/ipbans/create", middleware.RequireAdminAuth(admin.BanIPAddress))
|
||||
|
||||
// Remove an IP address ban
|
||||
http.HandleFunc("/api/admin/chat/users/ipbans/remove", middleware.RequireAdminAuth(admin.UnBanIPAddress))
|
||||
|
||||
// Return all the banned IP addresses
|
||||
http.HandleFunc("/api/admin/chat/users/ipbans", middleware.RequireAdminAuth(admin.GetIPAddressBans))
|
||||
|
||||
// Get a list of disabled users
|
||||
http.HandleFunc("/api/admin/chat/users/disabled", middleware.RequireAdminAuth(admin.GetDisabledUsers))
|
||||
|
||||
// Set moderator status for a user
|
||||
http.HandleFunc("/api/admin/chat/users/setmoderator", middleware.RequireAdminAuth(admin.UpdateUserModerator))
|
||||
|
||||
// Get a list of moderator users
|
||||
http.HandleFunc("/api/admin/chat/users/moderators", middleware.RequireAdminAuth(admin.GetModerators))
|
||||
|
||||
// return followers
|
||||
http.HandleFunc("/api/admin/followers", middleware.RequireAdminAuth(middleware.HandlePagination(controllers.GetFollowers)))
|
||||
|
||||
// Get a list of pending follow requests
|
||||
http.HandleFunc("/api/admin/followers/pending", middleware.RequireAdminAuth(admin.GetPendingFollowRequests))
|
||||
|
||||
// Get a list of rejected or blocked follows
|
||||
http.HandleFunc("/api/admin/followers/blocked", middleware.RequireAdminAuth(admin.GetBlockedAndRejectedFollowers))
|
||||
|
||||
// Set the following state of a follower or follow request.
|
||||
http.HandleFunc("/api/admin/followers/approve", middleware.RequireAdminAuth(admin.ApproveFollower))
|
||||
|
||||
// Upload custom emoji
|
||||
http.HandleFunc("/api/admin/emoji/upload", middleware.RequireAdminAuth(admin.UploadCustomEmoji))
|
||||
|
||||
// Delete custom emoji
|
||||
http.HandleFunc("/api/admin/emoji/delete", middleware.RequireAdminAuth(admin.DeleteCustomEmoji))
|
||||
|
||||
// Update config values
|
||||
|
||||
// Change the current streaming key in memory
|
||||
http.HandleFunc("/api/admin/config/adminpass", middleware.RequireAdminAuth(admin.SetAdminPassword))
|
||||
|
||||
// Set an array of valid stream keys
|
||||
http.HandleFunc("/api/admin/config/streamkeys", middleware.RequireAdminAuth(admin.SetStreamKeys))
|
||||
|
||||
// Change the extra page content in memory
|
||||
http.HandleFunc("/api/admin/config/pagecontent", middleware.RequireAdminAuth(admin.SetExtraPageContent))
|
||||
|
||||
// Stream title
|
||||
http.HandleFunc("/api/admin/config/streamtitle", middleware.RequireAdminAuth(admin.SetStreamTitle))
|
||||
|
||||
// Server name
|
||||
http.HandleFunc("/api/admin/config/name", middleware.RequireAdminAuth(admin.SetServerName))
|
||||
|
||||
// Server summary
|
||||
http.HandleFunc("/api/admin/config/serversummary", middleware.RequireAdminAuth(admin.SetServerSummary))
|
||||
|
||||
// Offline message
|
||||
http.HandleFunc("/api/admin/config/offlinemessage", middleware.RequireAdminAuth(admin.SetCustomOfflineMessage))
|
||||
|
||||
// Server welcome message
|
||||
http.HandleFunc("/api/admin/config/welcomemessage", middleware.RequireAdminAuth(admin.SetServerWelcomeMessage))
|
||||
|
||||
// Disable chat
|
||||
http.HandleFunc("/api/admin/config/chat/disable", middleware.RequireAdminAuth(admin.SetChatDisabled))
|
||||
|
||||
// Disable chat user join messages
|
||||
http.HandleFunc("/api/admin/config/chat/joinmessagesenabled", middleware.RequireAdminAuth(admin.SetChatJoinMessagesEnabled))
|
||||
|
||||
// Enable/disable chat established user mode
|
||||
http.HandleFunc("/api/admin/config/chat/establishedusermode", middleware.RequireAdminAuth(admin.SetEnableEstablishedChatUserMode))
|
||||
|
||||
// Set chat usernames that are not allowed
|
||||
http.HandleFunc("/api/admin/config/chat/forbiddenusernames", middleware.RequireAdminAuth(admin.SetForbiddenUsernameList))
|
||||
|
||||
// Set the suggested chat usernames that will be assigned automatically
|
||||
http.HandleFunc("/api/admin/config/chat/suggestedusernames", middleware.RequireAdminAuth(admin.SetSuggestedUsernameList))
|
||||
|
||||
// Enable or disable chat spam protection
|
||||
http.HandleFunc("/api/admin/config/chat/spamprotectionenabled", middleware.RequireAdminAuth(admin.SetChatSpamProtectionEnabled))
|
||||
|
||||
http.HandleFunc("/api/admin/config/chat/slurfilterenabled", middleware.RequireAdminAuth(admin.SetChatSlurFilterEnabled))
|
||||
|
||||
// Set video codec
|
||||
http.HandleFunc("/api/admin/config/video/codec", middleware.RequireAdminAuth(admin.SetVideoCodec))
|
||||
|
||||
// Set style/color/css values
|
||||
http.HandleFunc("/api/admin/config/appearance", middleware.RequireAdminAuth(admin.SetCustomColorVariableValues))
|
||||
|
||||
// Return all webhooks
|
||||
http.HandleFunc("/api/admin/webhooks", middleware.RequireAdminAuth(admin.GetWebhooks))
|
||||
|
||||
// Delete a single webhook
|
||||
http.HandleFunc("/api/admin/webhooks/delete", middleware.RequireAdminAuth(admin.DeleteWebhook))
|
||||
|
||||
// Create a single webhook
|
||||
http.HandleFunc("/api/admin/webhooks/create", middleware.RequireAdminAuth(admin.CreateWebhook))
|
||||
|
||||
// Get all access tokens
|
||||
http.HandleFunc("/api/admin/accesstokens", middleware.RequireAdminAuth(admin.GetExternalAPIUsers))
|
||||
|
||||
// Delete a single access token
|
||||
http.HandleFunc("/api/admin/accesstokens/delete", middleware.RequireAdminAuth(admin.DeleteExternalAPIUser))
|
||||
|
||||
// Create a single access token
|
||||
http.HandleFunc("/api/admin/accesstokens/create", middleware.RequireAdminAuth(admin.CreateExternalAPIUser))
|
||||
|
||||
// Return the auto-update features that are supported for this instance.
|
||||
http.HandleFunc("/api/admin/update/options", middleware.RequireAdminAuth(admin.AutoUpdateOptions))
|
||||
|
||||
// Begin the auto update
|
||||
http.HandleFunc("/api/admin/update/start", middleware.RequireAdminAuth(admin.AutoUpdateStart))
|
||||
|
||||
// Force quit the service to restart it
|
||||
http.HandleFunc("/api/admin/update/forcequit", middleware.RequireAdminAuth(admin.AutoUpdateForceQuit))
|
||||
|
||||
// Send a system message to chat
|
||||
http.HandleFunc("/api/integrations/chat/system", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendSystemMessage))
|
||||
|
||||
// Send a system message to a single client
|
||||
http.HandleFunc(utils.RestEndpoint("/api/integrations/chat/system/client/{clientId}", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendSystemMessageToConnectedClient)))
|
||||
|
||||
// Send a user message to chat *NO LONGER SUPPORTED
|
||||
http.HandleFunc("/api/integrations/chat/user", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendChatMessages, admin.SendUserMessage))
|
||||
|
||||
// Send a message to chat as a specific 3rd party bot/integration based on its access token
|
||||
http.HandleFunc("/api/integrations/chat/send", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendChatMessages, admin.SendIntegrationChatMessage))
|
||||
|
||||
// Send a user action to chat
|
||||
http.HandleFunc("/api/integrations/chat/action", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendChatAction))
|
||||
|
||||
// Hide chat message
|
||||
http.HandleFunc("/api/integrations/chat/messagevisibility", middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalUpdateMessageVisibility))
|
||||
|
||||
// Stream title
|
||||
http.HandleFunc("/api/integrations/streamtitle", middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalSetStreamTitle))
|
||||
|
||||
// Get chat history
|
||||
http.HandleFunc("/api/integrations/chat", middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, controllers.ExternalGetChatMessages))
|
||||
|
||||
// Connected clients
|
||||
http.HandleFunc("/api/integrations/clients", middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalGetConnectedChatClients))
|
||||
|
||||
// Logo path
|
||||
http.HandleFunc("/api/admin/config/logo", middleware.RequireAdminAuth(admin.SetLogo))
|
||||
|
||||
// Server tags
|
||||
http.HandleFunc("/api/admin/config/tags", middleware.RequireAdminAuth(admin.SetTags))
|
||||
|
||||
// ffmpeg
|
||||
http.HandleFunc("/api/admin/config/ffmpegpath", middleware.RequireAdminAuth(admin.SetFfmpegPath))
|
||||
|
||||
// Server http port
|
||||
http.HandleFunc("/api/admin/config/webserverport", middleware.RequireAdminAuth(admin.SetWebServerPort))
|
||||
|
||||
// Server http listen address
|
||||
http.HandleFunc("/api/admin/config/webserverip", middleware.RequireAdminAuth(admin.SetWebServerIP))
|
||||
|
||||
// Server rtmp port
|
||||
http.HandleFunc("/api/admin/config/rtmpserverport", middleware.RequireAdminAuth(admin.SetRTMPServerPort))
|
||||
|
||||
// Websocket host override
|
||||
http.HandleFunc("/api/admin/config/sockethostoverride", middleware.RequireAdminAuth(admin.SetSocketHostOverride))
|
||||
|
||||
// Custom video serving endpoint
|
||||
http.HandleFunc("/api/admin/config/videoservingendpoint", middleware.RequireAdminAuth(admin.SetVideoServingEndpoint))
|
||||
|
||||
// Is server marked as NSFW
|
||||
http.HandleFunc("/api/admin/config/nsfw", middleware.RequireAdminAuth(admin.SetNSFW))
|
||||
|
||||
// directory enabled
|
||||
http.HandleFunc("/api/admin/config/directoryenabled", middleware.RequireAdminAuth(admin.SetDirectoryEnabled))
|
||||
|
||||
// social handles
|
||||
http.HandleFunc("/api/admin/config/socialhandles", middleware.RequireAdminAuth(admin.SetSocialHandles))
|
||||
|
||||
// set the number of video segments and duration per segment in a playlist
|
||||
http.HandleFunc("/api/admin/config/video/streamlatencylevel", middleware.RequireAdminAuth(admin.SetStreamLatencyLevel))
|
||||
|
||||
// set an array of video output configurations
|
||||
http.HandleFunc("/api/admin/config/video/streamoutputvariants", middleware.RequireAdminAuth(admin.SetStreamOutputVariants))
|
||||
|
||||
// set s3 configuration
|
||||
http.HandleFunc("/api/admin/config/s3", middleware.RequireAdminAuth(admin.SetS3Configuration))
|
||||
|
||||
// set server url
|
||||
http.HandleFunc("/api/admin/config/serverurl", middleware.RequireAdminAuth(admin.SetServerURL))
|
||||
|
||||
// reset the YP registration
|
||||
http.HandleFunc("/api/admin/yp/reset", middleware.RequireAdminAuth(admin.ResetYPRegistration))
|
||||
|
||||
// set external action links
|
||||
http.HandleFunc("/api/admin/config/externalactions", middleware.RequireAdminAuth(admin.SetExternalActions))
|
||||
|
||||
// set custom style css
|
||||
http.HandleFunc("/api/admin/config/customstyles", middleware.RequireAdminAuth(admin.SetCustomStyles))
|
||||
|
||||
// set custom style javascript
|
||||
http.HandleFunc("/api/admin/config/customjavascript", middleware.RequireAdminAuth(admin.SetCustomJavascript))
|
||||
|
||||
// Video playback metrics
|
||||
http.HandleFunc("/api/admin/metrics/video", middleware.RequireAdminAuth(admin.GetVideoPlaybackMetrics))
|
||||
|
||||
// Is the viewer count hidden from viewers
|
||||
http.HandleFunc("/api/admin/config/hideviewercount", middleware.RequireAdminAuth(admin.SetHideViewerCount))
|
||||
|
||||
// set disabling of search indexing
|
||||
http.HandleFunc("/api/admin/config/disablesearchindexing", middleware.RequireAdminAuth(admin.SetDisableSearchIndexing))
|
||||
|
||||
// Inline chat moderation actions
|
||||
|
||||
// Update chat message visibility
|
||||
http.HandleFunc("/api/chat/messagevisibility", middleware.RequireUserModerationScopeAccesstoken(admin.UpdateMessageVisibility))
|
||||
|
||||
// Enable/disable a user
|
||||
http.HandleFunc("/api/chat/users/setenabled", middleware.RequireUserModerationScopeAccesstoken(admin.UpdateUserEnabled))
|
||||
|
||||
// Get a user's details
|
||||
http.HandleFunc("/api/moderation/chat/user/", middleware.RequireUserModerationScopeAccesstoken(moderation.GetUserDetails))
|
||||
|
||||
// Configure Federation features
|
||||
|
||||
// enable/disable federation features
|
||||
http.HandleFunc("/api/admin/config/federation/enable", middleware.RequireAdminAuth(admin.SetFederationEnabled))
|
||||
|
||||
// set if federation activities are private
|
||||
http.HandleFunc("/api/admin/config/federation/private", middleware.RequireAdminAuth(admin.SetFederationActivityPrivate))
|
||||
|
||||
// set if fediverse engagement appears in chat
|
||||
http.HandleFunc("/api/admin/config/federation/showengagement", middleware.RequireAdminAuth(admin.SetFederationShowEngagement))
|
||||
|
||||
// set local federated username
|
||||
http.HandleFunc("/api/admin/config/federation/username", middleware.RequireAdminAuth(admin.SetFederationUsername))
|
||||
|
||||
// set federated go live message
|
||||
http.HandleFunc("/api/admin/config/federation/livemessage", middleware.RequireAdminAuth(admin.SetFederationGoLiveMessage))
|
||||
|
||||
// Federation blocked domains
|
||||
http.HandleFunc("/api/admin/config/federation/blockdomains", middleware.RequireAdminAuth(admin.SetFederationBlockDomains))
|
||||
|
||||
// send a public message to the Fediverse from the server's user
|
||||
http.HandleFunc("/api/admin/federation/send", middleware.RequireAdminAuth(admin.SendFederatedMessage))
|
||||
|
||||
// Return federated activities
|
||||
http.HandleFunc("/api/admin/federation/actions", middleware.RequireAdminAuth(middleware.HandlePagination(admin.GetFederatedActions)))
|
||||
|
||||
// Prometheus metrics
|
||||
http.Handle("/api/admin/prometheus", middleware.RequireAdminAuth(func(rw http.ResponseWriter, r *http.Request) {
|
||||
promhttp.Handler().ServeHTTP(rw, r)
|
||||
}))
|
||||
|
||||
// Configure outbound notification channels.
|
||||
http.HandleFunc("/api/admin/config/notifications/discord", middleware.RequireAdminAuth(admin.SetDiscordNotificationConfiguration))
|
||||
http.HandleFunc("/api/admin/config/notifications/browser", middleware.RequireAdminAuth(admin.SetBrowserNotificationConfiguration))
|
||||
|
||||
// Auth
|
||||
|
||||
// Start auth flow
|
||||
http.HandleFunc("/api/auth/indieauth", middleware.RequireUserAccessToken(indieauth.StartAuthFlow))
|
||||
http.HandleFunc("/api/auth/indieauth/callback", indieauth.HandleRedirect)
|
||||
http.HandleFunc("/api/auth/provider/indieauth", indieauth.HandleAuthEndpoint)
|
||||
|
||||
http.HandleFunc("/api/auth/fediverse", middleware.RequireUserAccessToken(fediverseauth.RegisterFediverseOTPRequest))
|
||||
http.HandleFunc("/api/auth/fediverse/verify", fediverseauth.VerifyFediverseOTPRequest)
|
||||
// mount the api
|
||||
r.Mount("/api/", handler.New().Handler())
|
||||
|
||||
// ActivityPub has its own router
|
||||
activitypub.Start(data.GetDatastore())
|
||||
|
||||
// websocket
|
||||
http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
|
||||
chat.HandleClientConnection(w, r)
|
||||
})
|
||||
|
||||
// Optional public static files
|
||||
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir(config.PublicFilesPath))))
|
||||
|
||||
port := config.WebServerPort
|
||||
ip := config.WebServerIP
|
||||
|
||||
h2s := &http2.Server{}
|
||||
|
||||
// Create a custom mux handler to intercept the /debug/vars endpoint.
|
||||
// This is a hack because Prometheus enables this endpoint by default
|
||||
// due to its use of expvar and we do not want this exposed.
|
||||
defaultMux := h2c.NewHandler(http.DefaultServeMux, h2s)
|
||||
h2s := &http2.Server{}
|
||||
http2Handler := h2c.NewHandler(r, h2s)
|
||||
m := http.NewServeMux()
|
||||
|
||||
m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -427,10 +79,13 @@ func Start() error {
|
|||
// Redirect /embed/chat
|
||||
http.Redirect(w, r, "/embed/chat/readonly", http.StatusTemporaryRedirect)
|
||||
} else {
|
||||
defaultMux.ServeHTTP(w, r)
|
||||
http2Handler.ServeHTTP(w, r)
|
||||
}
|
||||
})
|
||||
|
||||
port := config.WebServerPort
|
||||
ip := config.WebServerIP
|
||||
|
||||
compress, _ := httpcompression.DefaultAdapter() // Use the default configuration
|
||||
server := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%d", ip, port),
|
||||
|
@ -447,3 +102,43 @@ func Start() error {
|
|||
|
||||
return server.ListenAndServe()
|
||||
}
|
||||
|
||||
func addStaticFileEndpoints(r chi.Router) {
|
||||
// Images
|
||||
r.HandleFunc("/thumbnail.jpg", controllers.GetThumbnail)
|
||||
r.HandleFunc("/preview.gif", controllers.GetPreview)
|
||||
r.HandleFunc("/logo", controllers.GetLogo)
|
||||
// return a logo that's compatible with external social networks
|
||||
r.HandleFunc("/logo/external", controllers.GetCompatibleLogo)
|
||||
|
||||
// Custom Javascript
|
||||
r.HandleFunc("/customjavascript", controllers.ServeCustomJavascript)
|
||||
|
||||
// robots.txt
|
||||
r.HandleFunc("/robots.txt", controllers.GetRobotsDotTxt)
|
||||
|
||||
// Return a single emoji image.
|
||||
emojiDir := config.EmojiDir
|
||||
if !strings.HasSuffix(emojiDir, "*") {
|
||||
emojiDir += "*"
|
||||
}
|
||||
r.HandleFunc(emojiDir, controllers.GetCustomEmojiImage)
|
||||
|
||||
// WebFinger
|
||||
r.HandleFunc("/.well-known/webfinger", apControllers.WebfingerHandler)
|
||||
|
||||
// Host Metadata
|
||||
r.HandleFunc("/.well-known/host-meta", apControllers.HostMetaController)
|
||||
|
||||
// Nodeinfo v1
|
||||
r.HandleFunc("/.well-known/nodeinfo", apControllers.NodeInfoController)
|
||||
|
||||
// x-nodeinfo v2
|
||||
r.HandleFunc("/.well-known/x-nodeinfo2", apControllers.XNodeInfo2Controller)
|
||||
|
||||
// Nodeinfo v2
|
||||
r.HandleFunc("/nodeinfo/2.0", apControllers.NodeInfoV2Controller)
|
||||
|
||||
// Instance details
|
||||
r.HandleFunc("/api/v1/instance", apControllers.InstanceV1Controller)
|
||||
}
|
||||
|
|
41
spec/gen-api.sh
Executable file
41
spec/gen-api.sh
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
|
||||
# go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest
|
||||
|
||||
# setup
|
||||
package="generated"
|
||||
folderPath="handler/generated"
|
||||
specPath="spec/openapi.yaml"
|
||||
|
||||
# validate scripts are installed
|
||||
if ! command -v swagger-cli &> /dev/null
|
||||
then
|
||||
echo "Please install \`swagger-cli\` before running this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v oapi-codegen &> /dev/null
|
||||
then
|
||||
echo "Please install \`oapi-codegen\` before running this script"
|
||||
echo "Hint: run \`go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest\` to install"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# validate schema
|
||||
swagger-cli validate $specPath
|
||||
if [ $? -ne 0 ];
|
||||
then
|
||||
echo "Open API specification is not valid"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# cleanup
|
||||
rm -r $folderPath
|
||||
mkdir -p $folderPath
|
||||
|
||||
# codegen
|
||||
oapi-codegen -generate types -o $folderPath/$package-types.gen.go -package $package $specPath
|
||||
oapi-codegen -generate "chi-server" -o $folderPath/$package.gen.go -package $package $specPath
|
||||
|
||||
# go
|
||||
go mod tidy
|
4114
spec/openapi.yaml
Normal file
4114
spec/openapi.yaml
Normal file
File diff suppressed because it is too large
Load diff
1
static/web/_next/static/chunks/7122-0f5c94dc81f8bbfc.js
vendored
Normal file
1
static/web/_next/static/chunks/7122-0f5c94dc81f8bbfc.js
vendored
Normal file
File diff suppressed because one or more lines are too long
27
static/web/_next/static/chunks/d6e1aeb5-286b2049d5ea26a0.js
vendored
Normal file
27
static/web/_next/static/chunks/d6e1aeb5-286b2049d5ea26a0.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
static/web/_next/static/chunks/main-d53fb6c7e10249a6.js
vendored
Normal file
1
static/web/_next/static/chunks/main-d53fb6c7e10249a6.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
static/web/_next/static/chunks/webpack-cc2976124aab378f.js
vendored
Normal file
1
static/web/_next/static/chunks/webpack-cc2976124aab378f.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
self.__SSG_MANIFEST=new Set,self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB();
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
const restURLPatternHeaderKey = "Owncast-Resturl-Pattern"
|
||||
const RestURLPatternHeaderKey = "Owncast-Resturl-Pattern"
|
||||
|
||||
// takes the segment pattern of an Url string and returns the segment before the first dynamic REST parameter.
|
||||
func getPatternForRestEndpoint(pattern string) string {
|
||||
|
@ -51,7 +51,7 @@ func readParameter(pattern string, requestURL string, paramName string) (string,
|
|||
|
||||
// ReadRestURLParameter will return the parameter from the request of the requested name.
|
||||
func ReadRestURLParameter(r *http.Request, parameterName string) (string, error) {
|
||||
pattern, found := r.Header[restURLPatternHeaderKey]
|
||||
pattern, found := r.Header[RestURLPatternHeaderKey]
|
||||
if !found {
|
||||
return "", fmt.Errorf("this HandlerFunc is not marked as REST-Endpoint. Cannot read Parameter '%s' from Request", parameterName)
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ func ReadRestURLParameter(r *http.Request, parameterName string) (string, error)
|
|||
func RestEndpoint(pattern string, handler http.HandlerFunc) (string, http.HandlerFunc) {
|
||||
baseURL := getPatternForRestEndpoint(pattern)
|
||||
return baseURL, func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Header[restURLPatternHeaderKey] = []string{pattern}
|
||||
r.Header[RestURLPatternHeaderKey] = []string{pattern}
|
||||
handler(w, r)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue