Skip to content

Register a custom scheme to the operating system and complete the custom processing

License

Notifications You must be signed in to change notification settings

chyroc/scheme_register

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scheme_register

Register a custom scheme to the operating system and complete the custom processing

Install

go get github.com/chyroc/scheme_register

Usage

if you want to write a app to handle myapp://path?a=b uri, just do this:

package main

import (
	"log"
	"os"

	"github.com/chyroc/scheme_register"
)

func main() {
	// setup log
	f, err := os.OpenFile("/tmp/log.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o666)
	if err != nil {
		panic(err)
	}
	log.SetOutput(f)
	log.SetPrefix("[example] ")
	log.SetFlags(log.LstdFlags)

	// run
	err = scheme_register.Register(&scheme_register.RegisterReq{
		Name:   "MyApp",
		Scheme: "myapp",
		Handler: func(url string) {
			log.Printf("get: %s", url)
		},
	})
	if err != nil {
		panic(err)
	}
}

About

Register a custom scheme to the operating system and complete the custom processing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published