Skip to content

Conversation

dinakajoy
Copy link
Contributor

open Cohttp
open Cohttp_lwt_unix

let template = {|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should show an example building templates with raw strings without any escaping. It's a very easy way to open up the server to injection attacks. There are multiple options for safer HTML templating/generation libraries that can be used.

@@ Dream.logger
@@ Dream.router [
Dream.get "/" (fun _ -> Dream.html template);
Dream.any "/" (fun _ -> Dream.empty `Not_Found);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave this out as Dream will just handle this automatically.

@dinakajoy dinakajoy requested a review from yawaramin July 1, 2025 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants