Update/root url (#136)

* handle root url

* add handler file

* fix compilation bug

* fix compilation error

* attempt redirect

* add query param of hostname

* add name to root query params

* cleanup
This commit is contained in:
Lucy
2023-06-19 14:53:06 -06:00
committed by GitHub
parent 683b9d1712
commit e4cd1bae09
4 changed files with 22 additions and 10 deletions

View File

@@ -1,6 +1,8 @@
/ RootR GET
-- EOS API V0 -- EOS API V0
/eos/v0/latest EosVersionR GET -- get eos information /eos/v0/latest EosVersionR GET -- get eos information
/eos/v0/eos.img EosR GET -- get eos.img /eos/v0/eos.img EosR GET -- get eos.img
-- PACKAGE API V0 -- PACKAGE API V0
/package/#ApiVersion/info InfoR GET -- get all marketplace categories /package/#ApiVersion/info InfoR GET -- get all marketplace categories
@@ -15,9 +17,9 @@
/package/#ApiVersion/version/#PkgId PkgVersionR GET -- get most recent appId version /package/#ApiVersion/version/#PkgId PkgVersionR GET -- get most recent appId version
-- ADMIN API V0 -- ADMIN API V0
/admin/v0/upload PkgUploadR POST !admin /admin/v0/upload PkgUploadR POST !admin
/admin/v0/eos-upload EosUploadR POST !admin /admin/v0/eos-upload EosUploadR POST !admin
/admin/v0/index PkgIndexR POST !admin /admin/v0/index PkgIndexR POST !admin
/admin/v0/deindex PkgDeindexR GET POST !admin /admin/v0/deindex PkgDeindexR GET POST !admin
/admin/v0/category/#Text CategoryR POST DELETE !admin /admin/v0/category/#Text CategoryR POST DELETE !admin
/admin/v0/categorize/#Text/#PkgId PkgCategorizeR POST DELETE !admin /admin/v0/categorize/#Text/#PkgId PkgCategorizeR POST DELETE !admin

View File

@@ -186,6 +186,7 @@ import Handler.Admin (
postPkgUploadR, postPkgUploadR,
) )
import Handler.Eos (getEosR, getEosVersionR) import Handler.Eos (getEosR, getEosVersionR)
import Handler.Root(getRootR)
import Handler.Package import Handler.Package
import Lib.Ssl ( import Lib.Ssl (
doesSslNeedRenew, doesSslNeedRenew,
@@ -214,7 +215,6 @@ import System.Posix.Process (exitImmediately)
import System.Time.Extra (sleep) import System.Time.Extra (sleep)
import Yesod (YesodPersist (runDB)) import Yesod (YesodPersist (runDB))
-- This line actually creates our YesodDispatch instance. It is the second half -- This line actually creates our YesodDispatch instance. It is the second half
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the -- of the call to mkYesodData which occurs in Foundation.hs. Please see the
-- comments there for more details. -- comments there for more details.

View File

@@ -154,7 +154,6 @@ import Database.Persist ((==.))
import Database.Persist (selectFirst) import Database.Persist (selectFirst)
import Database.Persist (entityVal) import Database.Persist (entityVal)
-- | The foundation datatype for your application. This can be a good place to -- | The foundation datatype for your application. This can be a good place to
-- keep settings and values requiring initialization before your application -- keep settings and values requiring initialization before your application
-- starts running, such as database connections. Every handler will have -- starts running, such as database connections. Every handler will have

11
src/Handler/Root.hs Normal file
View File

@@ -0,0 +1,11 @@
module Handler.Root where
import Startlude
import Yesod
import Foundation
import qualified Data.Text as T
import Settings (AppSettings(registryHostname, marketplaceName))
getRootR :: HandlerFor RegistryCtx ()
getRootR = do
(url, name) <- getsYesod $ (registryHostname &&& marketplaceName) . appSettings
redirect $ T.pack "https://marketplace.start9.com?api=" <> url <> T.pack "&name=" <> name