File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,20 @@ In an actual project we would be writing the code to disk instead of printing it
129
129
130
130
See [ this file] ( examples/UserAPI.hs ) for the full code with imports.
131
131
132
+ ## Auth-protected routes
133
+
134
+ If you use ` AuthProtect ` from ` Servant.API.Experimental.Auth ` , the following
135
+ code can be used:
136
+
137
+ ``` haskell
138
+ instance HasElmEndpoints api => HasElmEndpoints (AuthProtect " auth" :> api ) where
139
+ elmEndpoints' = elmEndpoints' @ (Header' '[ Required , Strict ] " Authorization" Token :> api )
140
+ ```
141
+
142
+ This makes endpoints under ` AuthProtect "auth" ` take an extra ` Token ` parameter
143
+ which are added as authorization headers to the requests. This assumes that
144
+ ` Token ` has appropriate instances for ` HasElmType ` and ` HasElmEncoder Text ` .
145
+
132
146
## Related projects
133
147
134
148
Libraries that use or are used by servant-to-elm:
You can’t perform that action at this time.
0 commit comments