log headers, add user agent to backend app
This commit is contained in:
@@ -5,6 +5,7 @@ import org.koin.core.annotation.Module
|
||||
import org.koin.core.annotation.Single
|
||||
import ru.shadowsparky.backend.data.EnvFetcher
|
||||
import ru.shadowsparky.backend.domain.JwtInfo
|
||||
import ru.shadowsparky.http.domain.UserAgentProvider
|
||||
import ru.shadowsparky.vbox.backend.di.DbModule
|
||||
import ru.shadowsparky.vbox.backend.di.HttpModule
|
||||
|
||||
@@ -20,6 +21,13 @@ class VboxModule {
|
||||
"server side data storage"
|
||||
)
|
||||
}
|
||||
|
||||
@Single
|
||||
fun provideUserAgent(): UserAgentProvider {
|
||||
return object : UserAgentProvider {
|
||||
override fun provide(): String? = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Module(
|
||||
|
||||
@@ -59,31 +59,23 @@ fun main() {
|
||||
|
||||
@OptIn(ExperimentalDecomposeApi::class, ExperimentalComposeUiApi::class)
|
||||
fun mainInternal() {
|
||||
val lifecycle = LifecycleRegistry()
|
||||
|
||||
startKoin<VBox>()
|
||||
|
||||
val lifecycle = LifecycleRegistry()
|
||||
val composeRoot = document.getElementById("compose-root") as HTMLElement
|
||||
|
||||
var rootRef: VBoxRootComponent? = null
|
||||
|
||||
val root: VBoxRootComponent = withWebHistory { stateKeeper: StateKeeper, deepLinkUrl: String? ->
|
||||
if (rootRef == null) {
|
||||
rootRef = createRoot(lifecycle, stateKeeper, deepLinkUrl)
|
||||
}
|
||||
rootRef
|
||||
}
|
||||
|
||||
hookPageVisibility(lifecycle)
|
||||
lifecycle.doOnResume { hideElementById("loader") }
|
||||
|
||||
ComposeViewport(viewportContainer = composeRoot, content = {
|
||||
val r = remember { root }
|
||||
|
||||
LaunchedEffect(null) {
|
||||
r.onFinish.collect { r.navReplace(Route.Loading()) }
|
||||
}
|
||||
|
||||
Box(Modifier.fillMaxSize().padding(WindowInsets.safeDrawing.asPaddingValues())) {
|
||||
Nav(r)
|
||||
}
|
||||
@@ -93,14 +85,12 @@ fun mainInternal() {
|
||||
private fun createRoot(
|
||||
lifecycle: LifecycleRegistry,
|
||||
stateKeeper: StateKeeper,
|
||||
deepLinkUrl: String?,
|
||||
deepLinkUrl: String?
|
||||
): VBoxRootComponent {
|
||||
val ctx = DefaultComponentContext(
|
||||
lifecycle = lifecycle, stateKeeper = stateKeeper
|
||||
)
|
||||
val deep = deepLinkUrl?.let { runCatching { UrlRoutes.parseUrl(it) }.getOrNull() }
|
||||
|
||||
val deep = deepLinkUrl?.let { UrlRoutes.parseUrl(it) }
|
||||
val initRoute: Route = deep ?: Route.default
|
||||
|
||||
return koin.get<RootFactory>().create(context = ctx, initStack = initRoute)
|
||||
}
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ class HttpClientSettings(
|
||||
install(Logging) {
|
||||
val isDebug = koin.getOrNull<AppConfig>()?.debug ?: false
|
||||
if (isDebug) {
|
||||
this.level = LogLevel.ALL
|
||||
this.level = LogLevel.HEADERS
|
||||
this.logger = object : Logger {
|
||||
override fun log(message: String) {
|
||||
log.d("Http", message)
|
||||
|
||||
Reference in New Issue
Block a user