Skip to content

Update schooner.hoon#4

Open
sigilante wants to merge 2 commits intodalten-collective:masterfrom
sigilante:master
Open

Update schooner.hoon#4
sigilante wants to merge 2 commits intodalten-collective:masterfrom
sigilante:master

Conversation

@sigilante
Copy link

This is a slightly messy version of what I have, pending discussion.

@sigilante
Copy link
Author

sigilante commented Sep 28, 2022

Should probably have some sort of builder arm that accepts text/html and yields ['content-type'^'text/html'] or similar.

@sigilante
Copy link
Author

What about something like this (untested)? Could have more linting but probably better to just break if GIGO.

++  response
  |=  [=eyre-id =http-status =headers =resource]
  ^-  (list card:agent:gall)
  %+  give-simple-payload:app:server
    eyre-id
  ^-  simple-payload:http
  ?+  -.resource
      ::  matches no standard type, try as octs
    :_  `(as-octt:mimes:html p.resource)
    :-  http-status
    =/  a  (trip -.resource)
    =/  b  (find "-" a)
    =/  c  (crip (snap a b '/'))
    (weld headers ['content-type'^c]~)
    ::
      %manx
    :-  :-  http-status
      (weld headers ['content-type'^'text/html']~)
    `(as-octt:mimes:html (en-xml:html m.resource))
    ::

@sigilante
Copy link
Author

This is the version that Urbit Foundation will distribute in %yard. It supports a wide variety of MIME types and a general-purpose arm in case you find something out of band.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant