Effect CommunityEC
Effect Community2y ago
45 replies
David Novák

HttpServer - How to get query params

Is there helper function to get query params from request url?

It's common practice to put params for get request into url query params. For example like this: /search?phrase=foo&limit=10 . Is there a function that can decode those into schema shape (the same as request.schemaBodyJson)? I can see there is function request.schemaBodyUrlParams to get form-encode params, but I can not find similar function to decode url query params.

It's doable parsing the url by myself like so:
Http.request.ServerRequest.pipe(
          Effect.map((r) => r.url),
          Effect.tap((a) => Effect.log('url:', a)) // we can parse it here...
        )


I just want to see if I have not missed anything. If not I'm eager to open a pull request ;).
Was this page helpful?