func HandleCreateStream(
	user *graylog.User, lgc *logic.Logic,
	w http.ResponseWriter, r *http.Request, _ httprouter.Params,
) (interface{}, int, error) {
	// POST /streams Create index set
	if sc, err := lgc.Authorize(user, "streams:create"); err != nil {
		return nil, sc, err
	}
	// empty description is ignored
	body, sc, err := validateRequestBody(
		r.Body, &validateReqBodyPrms{
			Required:     set.NewStrSet("title", "index_set_id"),
			Optional:     set.NewStrSet("rules", "description", "content_pack", "matching_type", "remove_matches_from_default_stream"),
			ExtForbidden: true,
		})
	if err != nil {
		return nil, sc, err
	}

	stream := &graylog.Stream{}
	if err := util.MSDecode(body, stream); err != nil {
		lgc.Logger().WithFields(log.Fields{
			"body": body, "error": err,
		}).Info("Failed to parse request body as stream")
		return nil, 400, err
	}

	sc, err = lgc.AddStream(stream)
	if err != nil {
		return nil, sc, err
	}
	return map[string]string{"stream_id": stream.ID}, sc, nil
}
// HandleCreateStream is the handler of Create a Stream API.
HandleCreateStream is the handler of Create a Stream API.
// HandleCreateStream is the handler of Create a Stream API .
func HandleCreateStream(
	user *graylog.User, lgc *logic.Logic,
	w http.ResponseWriter, r *http.Request, _ httprouter.Params,
) (interface{}, int, error) {
	if sc, err := lgc.Authorize(user, "streams:create"); err != nil {
		return nil, sc, err
	}
	body, sc, err := validateRequestBody(
		r.Body, &validateReqBodyPrms{
			Required:     set.NewStrSet("title", "index_set_id"),
			Optional:     set.NewStrSet("rules", "description", "content_pack", "matching_type", "remove_matches_from_default_stream"),
			ExtForbidden: true,
		})
	if err != nil {
		return nil, sc, err
	}
	stream := &graylog.Stream{}
	if err := util.MSDecode(body, stream); err != nil {
		lgc.Logger().WithFields(log.Fields{
			"body": body, "error": err,
		}).Info("Failed to parse request body as stream")
		return nil, 400, err
	}
	sc, err = lgc.AddStream(stream)
	if err != nil {
		return nil, sc, err
	}
	return map[string]string{"stream_id": stream.ID}, sc, nil
}
func HandleCreateStream ( user * graylog . User , lgc * logic . Logic , w http . ResponseWriter , r * http . Request , _ httprouter . Params , ) ( interface { } , int , error ) { if sc , err := lgc . Authorize ( user , " " ) ; err != nil { return nil , sc , err } body , sc , err := validateRequestBody ( r . Body , & validateReqBodyPrms { Required : set . NewStrSet ( " " , " " ) , Optional : set . NewStrSet ( " " , " " , " " , " " , " " ) , ExtForbidden : true , } ) if err != nil { return nil , sc , err } stream := & graylog . Stream { } if err := util . MSDecode ( body , stream ) ; err != nil { lgc . Logger ( ) . WithFields ( log . Fields { " " : body , " " : err , } ) . Info ( " " ) return nil , 400 , err } sc , err = lgc . AddStream ( stream ) if err != nil { return nil , sc , err } return map [ string ] string { " " : stream . ID } , sc , nil }
HandleCreateStream is the handler of Create a Stream API.
HandleCreateStream is the handler of Create a Stream API .
// POST /streams Create index set // empty description is ignored