mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 01:32:25 -05:00 
			
		
		
		
	additional faffing around with streaming
This commit is contained in:
		
					parent
					
						
							
								0cee5aa569
							
						
					
				
			
			
				commit
				
					
						42b8333d1b
					
				
			
		
					 9 changed files with 171 additions and 28 deletions
				
			
		|  | @ -10,6 +10,8 @@ import ( | |||
| ) | ||||
| 
 | ||||
| func (m *Module) StreamGETHandler(c *gin.Context) { | ||||
| 	l := m.log.WithField("func", "StreamGETHandler") | ||||
| 
 | ||||
| 	streamType := c.Query(StreamQueryKey) | ||||
| 	if streamType == "" { | ||||
| 		c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("no stream type provided under query key %s", StreamQueryKey)}) | ||||
|  | @ -33,14 +35,18 @@ func (m *Module) StreamGETHandler(c *gin.Context) { | |||
| 		ReadBufferSize:   1024, | ||||
| 		WriteBufferSize:  1024, | ||||
| 		Subprotocols:     []string{"wss"}, | ||||
| 		CheckOrigin: func(r *http.Request) bool { | ||||
| 			return true | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	conn, err := upgrader.Upgrade(c.Writer, c.Request, nil) | ||||
| 	if err != nil { | ||||
| 		l.Infof("error upgrading websocket connection: %s", err) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if errWithCode := m.processor.StreamForAccount(conn, account, streamType); errWithCode != nil { | ||||
| 	if errWithCode := m.processor.OpenStreamForAccount(conn, account, streamType); errWithCode != nil { | ||||
| 		c.JSON(errWithCode.Code(), errWithCode.Safe()) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue