github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/uri.go (about) 1 /* For license and copyright information please see the LEGAL file in the code repository */ 2 3 package protocol 4 5 // URI indicate "Uniform Resource Identifier". 6 // Although many URI schemes are named after protocols, this does not 7 // imply that use of these URIs will result in access to the resource 8 // via the named protocol. 9 // https://en.wikipedia.org/wiki/List_of_URI_schemes 10 // 11 // https://datatracker.ietf.org/doc/html/rfc3986#section-3: 12 // foo://example.com:8042/over/there?name=ferret#nose 13 // \_/ \______________/\_________/ \_________/ \__/ 14 // | | | | | 15 // scheme authority path query fragment 16 // | _____________________|__ 17 // / \ / \ 18 // urn:example:animal:ferret:nose 19 type URI interface { 20 Init(uri string) 21 Set(scheme, authority, path, query, fragment string) 22 23 URI() string // always return full URI e.g. HTTP-URL 24 25 Scheme() string 26 URI_Authority 27 Path() string 28 Query() string 29 Fragment() string 30 31 // Codec 32 } 33 34 type URI_Authority interface { 35 Authority() string // [ userinfo "@" ] host [ ":" port ] 36 37 URI_Userinfo 38 Host() string 39 Port() string 40 } 41 42 type URI_Userinfo interface { 43 Userinfo() string // "username[:password]" 44 45 Username() string 46 Password() string 47 } 48 49 // URL indicate "Uniform Resource Locators". 50 // https://datatracker.ietf.org/doc/html/rfc1738 51 type URL = URI 52 53 // https://en.wikipedia.org/wiki/Uniform_Resource_Name 54 type URN interface { 55 URI 56 // URI() string // e.g. "urn:isbn:0451450523" 57 // Scheme() string // always return "urn" 58 59 NID() string // NID is the namespace identifier e.g. "isbn" 60 NSS() string // NSS is the namespace-specific e.g. "0451450523" 61 }