-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from studiokaiji/feature-#34-subdomain-access
Feature #34 subdomain access
- Loading branch information
Showing
4 changed files
with
169 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tools | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/studiokaiji/nostr-webhost/hostr/cmd/consts" | ||
) | ||
|
||
func GetContentType(kind int) (string, error) { | ||
if kind == consts.KindWebhostHTML || kind == consts.KindWebhostReplaceableHTML { | ||
return "text/html; charset=utf-8", nil | ||
} else if kind == consts.KindWebhostCSS || kind == consts.KindWebhostReplaceableCSS { | ||
return "text/css; charset=utf-8", nil | ||
} else if kind == consts.KindWebhostJS || kind == consts.KindWebhostReplaceableJS { | ||
return "text/javascript; charset=utf-8", nil | ||
} else { | ||
return "", fmt.Errorf("Invalid Kind") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package tools | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/nbd-wtf/go-nostr/nip19" | ||
) | ||
|
||
func ResolvePubKey(npubOrHex string) (string, error) { | ||
// npubから始まる場合はデコードする | ||
if npubOrHex[0:4] == "npub" { | ||
_, v, err := nip19.Decode(npubOrHex) | ||
if err != nil { | ||
return "", fmt.Errorf("Invalid npub") | ||
} | ||
return v.(string), nil | ||
} else { | ||
_, err := nip19.EncodePublicKey(npubOrHex) | ||
if err != nil { | ||
return "", fmt.Errorf("Invalid pubkey") | ||
} | ||
} | ||
return npubOrHex, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters