Skip to content

Hi-Jack-Mocker is a project that leverages OkHttp3's interceptor to intercept and modify network requests and responses, allowing you to verify the UI easily.

License

Notifications You must be signed in to change notification settings

koreatlwls/Hi-Jack-Mocker

Repository files navigation

Hi-Jack-Mocker

License Maven Central

🎈 Hi-Jack-Mocker is a project that leverages OkHttp3's interceptor to intercept and modify network requests and responses, allowing you to verify the UI easily.

Request Response

Setup

To integrate Hi-Jack-Mocker into your Android project, follow these steps:

Adding the Dependency

You can add the project dependency using the following code:

debugImplementation("io.github.koreatlwls:hjm:0.2.1")

Note: This dependency must be added with debugImplementation and should not be included in the release environment.

Initialize Hi-Jack-Mocker in your application:

override fun onCreate() {
    super.onCreate()
    HiJackMocker.initialize(this)
}

Add the above code in the onCreate method of your Application class.

Configure OkHttpClient:

When creating your OkHttpClient instance, include the addHiJackMocker() method

Note: When using HttpLoggingInterceptor, the order in which interceptors are added is important.
You should add addHiJackMocker() first, followed by adding HttpLoggingInterceptor.

@Provides
@Singleton
fun provideHttpClient(): OkHttpClient =
    OkHttpClient.Builder()
        .readTimeout(TEN_SECONDS, TimeUnit.SECONDS)
        .connectTimeout(TEN_SECONDS, TimeUnit.SECONDS)
        .writeTimeout(TEN_SECONDS, TimeUnit.SECONDS)
        .addHiJackMocker()
        .addInterceptor(getLoggingInterceptor())
        .build()

Usage

Hjm Mode

To enable or disable the Hi-Jack-Mocker mode, use the ImageButton provided at the top of every activity.

This allows you to control whether the hjm mode is active.

Mode Off Mode On

Add/Delete

The Add/Delete function in HJM allows for adding or deleting values in a JsonArray.

Note: When adding a value, it is inserted as the first item with a random value, except when the value is of String type.

Add Delete

License

Copyright 2024 koreatlwls

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.

About

Hi-Jack-Mocker is a project that leverages OkHttp3's interceptor to intercept and modify network requests and responses, allowing you to verify the UI easily.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages