{"action":"opened","issue":{"url":"https://api.github.com/repos/haskell-servant/servant/issues/956","repository_url":"https://api.github.com/repos/haskell-servant/servant","labels_url":"https://api.github.com/repos/haskell-servant/servant/issues/956/labels{/name}","comments_url":"https://api.github.com/repos/haskell-servant/servant/issues/956/comments","events_url":"https://api.github.com/repos/haskell-servant/servant/issues/956/events","html_url":"https://github.com/haskell-servant/servant/issues/956","id":318232007,"number":956,"title":"HasContextEntry problem","user":{"login":"boj","id":50839,"avatar_url":"https://avatars1.githubusercontent.com/u/50839?v=4","gravatar_id":"","url":"https://api.github.com/users/boj","html_url":"https://github.com/boj","followers_url":"https://api.github.com/users/boj/followers","following_url":"https://api.github.com/users/boj/following{/other_user}","gists_url":"https://api.github.com/users/boj/gists{/gist_id}","starred_url":"https://api.github.com/users/boj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boj/subscriptions","organizations_url":"https://api.github.com/users/boj/orgs","repos_url":"https://api.github.com/users/boj/repos","events_url":"https://api.github.com/users/boj/events{/privacy}","received_events_url":"https://api.github.com/users/boj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-26T23:39:18Z","updated_at":"2018-04-26T23:39:18Z","closed_at":null,"author_association":"NONE","body":"I've abstracted out all of the server/logging/whatever logic into a small library for my team, however, when I go to implement the `server-auth` version I get a no instance error I don't understand.\r\n\r\n```haskell\r\n-- Routes and api are standard Servant types and functions\r\nrun :: AppConfig -> Config MyConfig -> IO ()\r\nrun = runAuthApp (Proxy :: Proxy Routes) api\r\n```\r\n\r\n```haskell\r\nrunAuthApp :: forall proxy a. forall b.\r\n     (HasServer a '[CookieSettings, JWTSettings], HasServer a '[], HasSwagger a)\r\n  => proxy a\r\n  -> (JWTSettings -> ServerT a (AppT b))\r\n  -> AppConfig\r\n  -> Config b\r\n  -> IO ()\r\nrunAuthApp v rs ac cfg =\r\n  unless (checkFlag ac) $ do\r\n    k <- generateKey\r\n    let jwts = defaultJWTSettings k\r\n        ccs  = defaultCookieSettings :. jwts :. EmptyContext\r\n    runLoggedApp cfg (authApp v rs ccs jwts)\r\n\r\nrunLoggedApp :: Config a -> (AppContext a -> Wai.Application) -> IO ()\r\nrunLoggedApp cfg a =\r\n  -- log handling and init stuff skipped over\r\n  -- runs the app with Warp\r\n\r\nauthApp :: forall proxy a. forall b.\r\n     (HasServer a '[CookieSettings, JWTSettings], HasServer a '[], HasSwagger a)\r\n  => proxy a\r\n  -> (JWTSettings -> ServerT a (AppT b))\r\n  -> Context '[CookieSettings, JWTSettings]\r\n  -> JWTSettings\r\n  -> AppContext b\r\n  -> Wai.Application\r\nauthApp v rs sctx jwts ctx =\r\n  let p = Proxy :: Proxy (a :<|> SwaggerRoutes)\r\n  in serveWithContext p sctx (authServer v rs jwts ctx :<|> swaggerServer v ctx)\r\n\r\nauthServer :: forall proxy a. forall b. HasServer a '[CookieSettings, JWTSettings]\r\n  => proxy a\r\n  -> (JWTSettings -> ServerT a (AppT b))\r\n  -> JWTSettings\r\n  -> AppContext b\r\n  -> Server a\r\nauthServer _ rs jwts ctx =\r\n  let p = Proxy :: Proxy a\r\n      c = Proxy :: Proxy '[CookieSettings, JWTSettings]\r\n      h = toHandler ctx\r\n      r = rs jwts\r\n  in hoistServerWithContext p c h r\r\n```\r\n\r\nThe trouble is:\r\n\r\n```\r\nsrc/App.hs:19:7: error:\r\n    • No instance for (Servant.Server.Internal.Context.HasContextEntry\r\n                         '[] Servant.Auth.Server.Internal.ConfigTypes.JWTSettings)\r\n        arising from a use of ‘runAuthApp’\r\n    • In the expression: runAuthApp (Proxy :: Proxy Routes) api\r\n      In an equation for ‘run’:\r\n          run = runAuthApp (Proxy :: Proxy Routes) api\r\n   |\r\n19 | run = runAuthApp (Proxy :: Proxy Routes) api\r\n   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n```\r\n\r\nI'm not sure where I should be defining this instance, or what I missed otherwise. Any tips?\r\n\r\n"}}
{"actor":{"display_login":"boj"}}