-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ports in EndpointRouting #491
Comments
Would authorizeRequest work here? let webApp =
choose [
route "/ping" >=> text "pong"
route "/" >=> htmlView indexView
authorizeRequest
(fun x -> x.Request.Host.Port = 2000)
(text "failed") >=>
route "/healthcheck" >=> text "healthy"] |
I'm not using Giraffe anymore, though it looks to me that that wouldn't compile down to the efficient EndpointRouting stuff. |
You're correct. That would not compile down (I was using the default routing). Here's a version that does: let validateApiKey (ctx : HttpContext) =
match ctx.TryGetRequestHeader "X-API-Key" with
| Some key -> "super-sercret-key".Equals key
| None -> false
let accessDenied = setStatusCode 401 >=> text "Access Denied"
let requiresApiKey =
authorizeRequest validateApiKey accessDenied
let endpoints : Endpoint list =
[
GET [
route "/ping" (text "pong")
route "/" (htmlView indexView)
route "/healthCheck" (requiresApiKey >=> (text "healthy"))]] I assume swapping in a port check would work fine: let validatePort (ctx : HttpContext) = ctx.Request.Host.Port = 2000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If seems right now that there is no way to add ports during endpoint routing. AFAICT, it should be straightforward to add by calling
RequireHost
($"*:{port}")
.I want to ensure that my main routes (including fallbacks, authorization, redirects, etc) are not in the routing map for http calls to my control plane (healthcheck, kubernetes actions, etc) which are on a different port.
The text was updated successfully, but these errors were encountered: