mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-25 13:16:40 +00:00
move mastotypes
This commit is contained in:
parent
772f6e5949
commit
7590eb9cc2
|
@ -19,4 +19,42 @@
|
|||
package oauth
|
||||
|
||||
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…
Reference in a new issue