mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 10:42:24 -05:00 
			
		
		
		
	add a lil helper for generating user uris
This commit is contained in:
		
					parent
					
						
							
								f5224ad3a7
							
						
					
				
			
			
				commit
				
					
						dba33c2c5c
					
				
			
		
					 2 changed files with 57 additions and 16 deletions
				
			
		
							
								
								
									
										32
									
								
								internal/util/parse.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								internal/util/parse.go
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| package util | ||||
| 
 | ||||
| import "fmt" | ||||
| 
 | ||||
| type URIs struct { | ||||
| 	HostURL       string | ||||
| 	UserURL       string | ||||
| 	UserURI       string | ||||
| 	InboxURL      string | ||||
| 	OutboxURL     string | ||||
| 	FollowersURL  string | ||||
| 	CollectionURL string | ||||
| } | ||||
| 
 | ||||
| func GenerateURIs(username string, protocol string, host string) *URIs { | ||||
| 	hostURL := fmt.Sprintf("%s://%s", protocol, host) | ||||
| 	userURL := fmt.Sprintf("%s/@%s", hostURL, username) | ||||
| 	userURI := fmt.Sprintf("%s/users/%s", hostURL, username) | ||||
| 	inboxURL := fmt.Sprintf("%s/inbox", userURI) | ||||
| 	outboxURL := fmt.Sprintf("%s/outbox", userURI) | ||||
| 	followersURL := fmt.Sprintf("%s/followers", userURI) | ||||
| 	collectionURL := fmt.Sprintf("%s/collections/featured", userURI) | ||||
| 	return &URIs{ | ||||
| 		HostURL:       hostURL, | ||||
| 		UserURL:       userURL, | ||||
| 		UserURI:       userURI, | ||||
| 		InboxURL:      inboxURL, | ||||
| 		OutboxURL:     outboxURL, | ||||
| 		FollowersURL:  followersURL, | ||||
| 		CollectionURL: collectionURL, | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue