get single share
This commit is contained in:
		
							parent
							
								
									361123baca
								
							
						
					
					
						commit
						0a74ecf651
					
				@ -70,6 +70,31 @@ func StartWebserver(addr string, client client.Client, username, password string
 | 
			
		||||
		json.NewEncoder(w).Encode(shares)
 | 
			
		||||
	}).Methods("GET")
 | 
			
		||||
 | 
			
		||||
	r.HandleFunc("/api/share/{slug:[a-zA-Z0-9]{6}}", func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		if !checkAuth(w, r, username, password) {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		vars := mux.Vars(r)
 | 
			
		||||
		slug := vars["slug"]
 | 
			
		||||
 | 
			
		||||
		share, err := client.GetShare(r.Context(), slug)
 | 
			
		||||
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			logrus.Error(err.Error())
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if share == nil {
 | 
			
		||||
			http.NotFound(w, r)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		w.Header().Set("Content-Type", "application/json")
 | 
			
		||||
		json.NewEncoder(w).Encode(share)
 | 
			
		||||
	}).Methods("GET")
 | 
			
		||||
 | 
			
		||||
	r.HandleFunc("/api/share", func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		if !checkAuth(w, r, username, password) {
 | 
			
		||||
			return
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user