'What's the correct way to self-host a Deno library?

I've set up an apache2 server and have located my library at http://example.com/lib/deno/[email protected]/ and then created a 301 redirect from http://example.com/lib/deno/test/ to the former. In VS Code (using deno plugin) I noticed that when I import something like https://deno.land/std/http/server.ts I get a warning message:

Implicitly using latest version (0.140.0) for https://deno.land/std/http/server.ts deno(deno-warn)

Following the url it re-directs to https://deno.land/[email protected]/http/server.ts

However when I import my own http://example.com/lib/deno/test/mod.ts I do not get a similar message. Is this warning somehow hard coded to only work with deno.land or am I not hosting things correctly?



Solution 1:[1]

The "Implicitly using latest version" message is actually transmitted by the deno.land server as an HTTP response header. To serve a similar warning message from your own server, you will need to add a similar response header to your HTTP 302 redirect responses. You can supply any message to be displayed.

The response header from deno.land can be viewed like so:

> curl -XGET -I https://deno.land/std/http/server.ts
HTTP/2 302 
location: /[email protected]/http/server.ts
x-deno-warning: Implicitly using latest version (0.140.0) for https://deno.land/std/http/server.ts

How you attach this header to your redirects will depend on your web server.

For reference, you can view the relevant deno.land/x source on Github: https://github.com/denoland/dotland/blob/cd43f5f4a8d2dcb8982f96c0265dde8c8d69a304/routes/x/module.tsx#L638-L645

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 danopia