Documentation ¶
Overview ¶
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func Error(w http.ResponseWriter, r *http.Request, status int, err error)
- func GetUrlPattern(url string) string
- func LogError(w http.ResponseWriter, r *http.Request, err error)
- func NewTlsConfig(conf *configuration.Config) (*tls.Config, error)
- func Validate(w http.ResponseWriter, r *http.Request, validateBody bool) (string, string, []byte, log.Fields, error)
- func WebMetrics(m *AppMetrics, next http.Handler) http.Handler
- func WriteContentTypeAndResponse(w http.ResponseWriter, r *http.Request, rbytes []byte, version string, ...)
- func WriteErrorResponse(w http.ResponseWriter, r *http.Request, status int, err error)
- func WriteFactoryResetResponse(w http.ResponseWriter)
- func WriteMultipartResponse(w http.ResponseWriter, r *http.Request, o *MultipartOutput)
- func WriteOkResponse(w http.ResponseWriter, r *http.Request, data interface{})
- func WriteOkResponseByTemplate(w http.ResponseWriter, r *http.Request, dataStr string)
- func WriteResponseBytes(w http.ResponseWriter, r *http.Request, rbytes []byte, statusCode int, ...)
- func WriteTR181Response(w http.ResponseWriter, r *http.Request, params string, version string)
- type AppMetrics
- type CodebigConnector
- type CodebigResponse
- type ErrorResponse
- type HttpClient
- type MultipartOutput
- type PostTokenBody
- type WebconfigServer
- func (s *WebconfigServer) ApiMiddleware(next http.Handler) http.Handler
- func (s *WebconfigServer) CpeMiddleware(next http.Handler) http.Handler
- func (s *WebconfigServer) CreateTokenHandler(w http.ResponseWriter, r *http.Request)
- func (s *WebconfigServer) DeleteDocumentHandler(w http.ResponseWriter, r *http.Request)
- func (s *WebconfigServer) DeviceApiTokenAuthEnabled() bool
- func (s *WebconfigServer) FactoryResetEnabled() bool
- func (s *WebconfigServer) GetBaseRouter(testOnly bool) *mux.Router
- func (s *WebconfigServer) GetDocumentHandler(w http.ResponseWriter, r *http.Request)
- func (s *WebconfigServer) GetRouter(testOnly bool) *mux.Router
- func (s *WebconfigServer) GetSupportedGroupsHandler(w http.ResponseWriter, r *http.Request)
- func (s *WebconfigServer) MetricsEnabled() bool
- func (s *WebconfigServer) MonitorHandler(w http.ResponseWriter, r *http.Request)
- func (s *WebconfigServer) MultipartConfigHandler(w http.ResponseWriter, r *http.Request)
- func (s *WebconfigServer) NoAuthMiddleware(next http.Handler) http.Handler
- func (s *WebconfigServer) NotLoggedHeaders() []string
- func (s *WebconfigServer) NotificationHandler(w http.ResponseWriter, r *http.Request)
- func (c *WebconfigServer) Poke(cpeMac string, token string, fields log.Fields) (string, error)
- func (s *WebconfigServer) PokeHandler(w http.ResponseWriter, r *http.Request)
- func (s *WebconfigServer) PostDocumentHandler(w http.ResponseWriter, r *http.Request)
- func (s *WebconfigServer) ServerApiTokenAuthEnabled() bool
- func (s *WebconfigServer) ServerConfigHandler(w http.ResponseWriter, r *http.Request)
- func (s *WebconfigServer) SetDeviceApiTokenAuthEnabled(enabled bool)
- func (s *WebconfigServer) SetFactoryResetEnabled(enabled bool)
- func (s *WebconfigServer) SetServerApiTokenAuthEnabled(enabled bool)
- func (s *WebconfigServer) SetTokenApiEnabled(enabled bool)
- func (s *WebconfigServer) TestingCpeMiddleware(next http.Handler) http.Handler
- func (s *WebconfigServer) TestingMiddleware(next http.Handler) http.Handler
- func (s *WebconfigServer) TlsConfig() *tls.Config
- func (s *WebconfigServer) TokenApiEnabled() bool
- func (s *WebconfigServer) VersionHandler(w http.ResponseWriter, r *http.Request)
- type WebpaConnector
- type XpcResponseWriter
- func (w *XpcResponseWriter) Audit() log.Fields
- func (w *XpcResponseWriter) AuditData(k string) string
- func (w *XpcResponseWriter) AuditId() string
- func (w *XpcResponseWriter) Body() string
- func (xw *XpcResponseWriter) LogDebug(r *http.Request, logger string, message string)
- func (xw *XpcResponseWriter) LogInfo(r *http.Request, logger string, message string)
- func (xw *XpcResponseWriter) LogWarn(r *http.Request, logger string, message string)
- func (w *XpcResponseWriter) Response() string
- func (w *XpcResponseWriter) SetAuditData(k string, v interface{})
- func (w *XpcResponseWriter) SetBody(body string)
- func (w *XpcResponseWriter) SetBodyObfuscated(obfuscated bool)
- func (w *XpcResponseWriter) StartTime() time.Time
- func (w *XpcResponseWriter) Status() int
- func (w *XpcResponseWriter) String() string
- func (w *XpcResponseWriter) Token() string
- func (w *XpcResponseWriter) TraceId() string
- func (w *XpcResponseWriter) Write(b []byte) (int, error)
- func (w *XpcResponseWriter) WriteHeader(status int)
Constants ¶
const ( Boundary = "2xKIxjfJuErFW+hmNCwEoMoY8I+ECM9efrV6EI4efSSW9QjI" Linebreak = '\n' MsgpackContentType = "Content-type: application/msgpack\r\n" )
const ( OkResponseTemplate = `{"status":200,"message":"OK","data":%v}` TR181ResponseTemplate = `{"parameters":%v,"version":"%v"}` )
const ( LevelWarn = iota LevelInfo LevelDebug MetricsEnabledDefault = true FactoryResetEnabledDefault = false )
const AppName = "webconfig"
Variables ¶
var ( FirstLineBoundary = fmt.Sprintf("--%s\r\n", Boundary) LineBoundary = fmt.Sprintf("\r\n--%s\r\n", Boundary) LastLineBoundary = fmt.Sprintf("\r\n--%s--\r\n", Boundary) MultipartContentType = fmt.Sprintf("multipart/mixed; boundary=%s", Boundary) )
var (
PokeBody = []byte(`{"parameters":[{"dataType":0,"name":"Device.X_RDK_WebConfig.ForceSync","value":"root"}]}`)
)
Functions ¶
func GetUrlPattern ¶
func NewTlsConfig ¶
func NewTlsConfig(conf *configuration.Config) (*tls.Config, error)
func WebMetrics ¶
func WebMetrics(m *AppMetrics, next http.Handler) http.Handler
func WriteContentTypeAndResponse ¶
func WriteContentTypeAndResponse(w http.ResponseWriter, r *http.Request, rbytes []byte, version string, contentType string)
this is used to return default tr-181 payload while the cpe is not in the db
func WriteErrorResponse ¶
helper function to write a failure json response into ResponseWriter
func WriteFactoryResetResponse ¶
func WriteFactoryResetResponse(w http.ResponseWriter)
func WriteMultipartResponse ¶
func WriteMultipartResponse(w http.ResponseWriter, r *http.Request, o *MultipartOutput)
func WriteOkResponse ¶
func WriteOkResponse(w http.ResponseWriter, r *http.Request, data interface{})
helper function to wirte a json response into ResponseWriter
func WriteOkResponseByTemplate ¶
func WriteOkResponseByTemplate(w http.ResponseWriter, r *http.Request, dataStr string)
func WriteResponseBytes ¶
func WriteTR181Response ¶
Types ¶
type AppMetrics ¶
type AppMetrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
func NewMetrics() *AppMetrics
type CodebigConnector ¶
type CodebigConnector struct { *HttpClient // contains filtered or unexported fields }
func NewCodebigConnector ¶
func NewCodebigConnector(conf *configuration.Config, satClientId, satClientSecret string, tlsConfig *tls.Config) *CodebigConnector
func (*CodebigConnector) CodebigHost ¶
func (c *CodebigConnector) CodebigHost() string
func (*CodebigConnector) SetCodebigHost ¶
func (c *CodebigConnector) SetCodebigHost(host string)
type CodebigResponse ¶
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
}
type HttpClient ¶
func NewHttpClient ¶
func NewHttpClient(conf *configuration.Config, serviceName string, tlsConfig *tls.Config) *HttpClient
type MultipartOutput ¶
type MultipartOutput struct {
// contains filtered or unexported fields
}
func NewMultipartOutput ¶
func NewMultipartOutput(mparts []common.Multipart, rootVersion string) *MultipartOutput
func (*MultipartOutput) Mparts ¶
func (o *MultipartOutput) Mparts() []common.Multipart
func (*MultipartOutput) RootVersion ¶
func (o *MultipartOutput) RootVersion() string
type PostTokenBody ¶
type WebconfigServer ¶
type WebconfigServer struct { *http.Server db.DatabaseClient *security.TokenManager *common.ServerConfig *WebpaConnector *CodebigConnector // contains filtered or unexported fields }
func NewWebconfigServer ¶
func NewWebconfigServer(sc *common.ServerConfig, testOnly bool, dc db.DatabaseClient) *WebconfigServer
testOnly=true ==> running unit test
func (*WebconfigServer) ApiMiddleware ¶
func (s *WebconfigServer) ApiMiddleware(next http.Handler) http.Handler
Token valid enough
func (*WebconfigServer) CpeMiddleware ¶
func (s *WebconfigServer) CpeMiddleware(next http.Handler) http.Handler
Token valid and mac must match
func (*WebconfigServer) CreateTokenHandler ¶
func (s *WebconfigServer) CreateTokenHandler(w http.ResponseWriter, r *http.Request)
func (*WebconfigServer) DeleteDocumentHandler ¶
func (s *WebconfigServer) DeleteDocumentHandler(w http.ResponseWriter, r *http.Request)
func (*WebconfigServer) DeviceApiTokenAuthEnabled ¶
func (s *WebconfigServer) DeviceApiTokenAuthEnabled() bool
func (*WebconfigServer) FactoryResetEnabled ¶
func (s *WebconfigServer) FactoryResetEnabled() bool
func (*WebconfigServer) GetBaseRouter ¶
func (s *WebconfigServer) GetBaseRouter(testOnly bool) *mux.Router
func (*WebconfigServer) GetDocumentHandler ¶
func (s *WebconfigServer) GetDocumentHandler(w http.ResponseWriter, r *http.Request)
func (*WebconfigServer) GetSupportedGroupsHandler ¶
func (s *WebconfigServer) GetSupportedGroupsHandler(w http.ResponseWriter, r *http.Request)
XPC-10013 the supported doc header in GET /config is parsed and stored as a bitmap
this API returns the bitmap in read friendly json
func (*WebconfigServer) MetricsEnabled ¶
func (s *WebconfigServer) MetricsEnabled() bool
func (*WebconfigServer) MonitorHandler ¶
func (s *WebconfigServer) MonitorHandler(w http.ResponseWriter, r *http.Request)
func (*WebconfigServer) MultipartConfigHandler ¶
func (s *WebconfigServer) MultipartConfigHandler(w http.ResponseWriter, r *http.Request)
func (*WebconfigServer) NoAuthMiddleware ¶
func (s *WebconfigServer) NoAuthMiddleware(next http.Handler) http.Handler
func (*WebconfigServer) NotLoggedHeaders ¶
func (s *WebconfigServer) NotLoggedHeaders() []string
func (*WebconfigServer) NotificationHandler ¶
func (s *WebconfigServer) NotificationHandler(w http.ResponseWriter, r *http.Request)
func (*WebconfigServer) PokeHandler ¶
func (s *WebconfigServer) PokeHandler(w http.ResponseWriter, r *http.Request)
func (*WebconfigServer) PostDocumentHandler ¶
func (s *WebconfigServer) PostDocumentHandler(w http.ResponseWriter, r *http.Request)
func (*WebconfigServer) ServerApiTokenAuthEnabled ¶
func (s *WebconfigServer) ServerApiTokenAuthEnabled() bool
func (*WebconfigServer) ServerConfigHandler ¶
func (s *WebconfigServer) ServerConfigHandler(w http.ResponseWriter, r *http.Request)
func (*WebconfigServer) SetDeviceApiTokenAuthEnabled ¶
func (s *WebconfigServer) SetDeviceApiTokenAuthEnabled(enabled bool)
func (*WebconfigServer) SetFactoryResetEnabled ¶
func (s *WebconfigServer) SetFactoryResetEnabled(enabled bool)
func (*WebconfigServer) SetServerApiTokenAuthEnabled ¶
func (s *WebconfigServer) SetServerApiTokenAuthEnabled(enabled bool)
func (*WebconfigServer) SetTokenApiEnabled ¶
func (s *WebconfigServer) SetTokenApiEnabled(enabled bool)
func (*WebconfigServer) TestingCpeMiddleware ¶
func (s *WebconfigServer) TestingCpeMiddleware(next http.Handler) http.Handler
func (*WebconfigServer) TestingMiddleware ¶
func (s *WebconfigServer) TestingMiddleware(next http.Handler) http.Handler
func (*WebconfigServer) TlsConfig ¶
func (s *WebconfigServer) TlsConfig() *tls.Config
func (*WebconfigServer) TokenApiEnabled ¶
func (s *WebconfigServer) TokenApiEnabled() bool
func (*WebconfigServer) VersionHandler ¶
func (s *WebconfigServer) VersionHandler(w http.ResponseWriter, r *http.Request)
type WebpaConnector ¶
type WebpaConnector struct { *HttpClient // contains filtered or unexported fields }
func NewWebpaConnector ¶
func NewWebpaConnector(conf *configuration.Config, tlsConfig *tls.Config) *WebpaConnector
func (*WebpaConnector) SetWebpaHost ¶
func (c *WebpaConnector) SetWebpaHost(host string)
func (*WebpaConnector) WebpaHost ¶
func (c *WebpaConnector) WebpaHost() string
type XpcResponseWriter ¶
type XpcResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func NewXpcResponseWriter ¶
func NewXpcResponseWriter(w http.ResponseWriter, vargs ...interface{}) *XpcResponseWriter
func (*XpcResponseWriter) Audit ¶
func (w *XpcResponseWriter) Audit() log.Fields
func (*XpcResponseWriter) AuditData ¶
func (w *XpcResponseWriter) AuditData(k string) string
func (*XpcResponseWriter) AuditId ¶
func (w *XpcResponseWriter) AuditId() string
func (*XpcResponseWriter) Body ¶
func (w *XpcResponseWriter) Body() string
func (*XpcResponseWriter) LogDebug ¶
func (xw *XpcResponseWriter) LogDebug(r *http.Request, logger string, message string)
func (*XpcResponseWriter) LogInfo ¶
func (xw *XpcResponseWriter) LogInfo(r *http.Request, logger string, message string)
func (*XpcResponseWriter) LogWarn ¶
func (xw *XpcResponseWriter) LogWarn(r *http.Request, logger string, message string)
func (*XpcResponseWriter) Response ¶
func (w *XpcResponseWriter) Response() string
func (*XpcResponseWriter) SetAuditData ¶
func (w *XpcResponseWriter) SetAuditData(k string, v interface{})
func (*XpcResponseWriter) SetBody ¶
func (w *XpcResponseWriter) SetBody(body string)
func (*XpcResponseWriter) SetBodyObfuscated ¶
func (w *XpcResponseWriter) SetBodyObfuscated(obfuscated bool)
func (*XpcResponseWriter) StartTime ¶
func (w *XpcResponseWriter) StartTime() time.Time
func (*XpcResponseWriter) String ¶
func (w *XpcResponseWriter) String() string
func (*XpcResponseWriter) Token ¶
func (w *XpcResponseWriter) Token() string
func (*XpcResponseWriter) TraceId ¶
func (w *XpcResponseWriter) TraceId() string
func (*XpcResponseWriter) WriteHeader ¶
func (w *XpcResponseWriter) WriteHeader(status int)
interface/override