mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 23:12:25 -05:00 
			
		
		
		
	move mastotypes
This commit is contained in:
		
					parent
					
						
							
								772f6e5949
							
						
					
				
			
			
				commit
				
					
						7590eb9cc2
					
				
			
		
					 32 changed files with 38 additions and 0 deletions
				
			
		|  | @ -19,4 +19,42 @@ | ||||||
| package oauth | package oauth | ||||||
| 
 | 
 | ||||||
| type Server struct { | type Server struct { | ||||||
|  |    manager := manage.NewDefaultManager() | ||||||
|  | 	// token memory store | ||||||
|  | 	manager.MustTokenStorage(store.NewMemoryTokenStore()) | ||||||
|  | 
 | ||||||
|  | 	// client memory store | ||||||
|  | 	clientStore := store.NewClientStore() | ||||||
|  | 	clientStore.Set("000000", &models.Client{ | ||||||
|  | 		ID:     "000000", | ||||||
|  | 		Secret: "999999", | ||||||
|  | 		Domain: "http://localhost", | ||||||
|  | 	}) | ||||||
|  | 	manager.MapClientStorage(clientStore) | ||||||
|  | 
 | ||||||
|  | 	srv := server.NewDefaultServer(manager) | ||||||
|  | 	srv.SetAllowGetAccessRequest(true) | ||||||
|  | 	srv.SetClientInfoHandler(server.ClientFormHandler) | ||||||
|  | 
 | ||||||
|  | 	srv.SetInternalErrorHandler(func(err error) (re *errors.Response) { | ||||||
|  | 		log.Println("Internal Error:", err.Error()) | ||||||
|  | 		return | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
|  | 	srv.SetResponseErrorHandler(func(re *errors.Response) { | ||||||
|  | 		log.Println("Response Error:", re.Error.Error()) | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
|  | 	http.HandleFunc("/authorize", func(w http.ResponseWriter, r *http.Request) { | ||||||
|  | 		err := srv.HandleAuthorizeRequest(w, r) | ||||||
|  | 		if err != nil { | ||||||
|  | 			http.Error(w, err.Error(), http.StatusBadRequest) | ||||||
|  | 		} | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
|  | 	http.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) { | ||||||
|  | 		srv.HandleTokenRequest(w, r) | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
|  | 	log.Fatal(http.ListenAndServe(":9096", nil)) | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue